intro.rst 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. =============================
  2. Introduction to Task Queues
  3. =============================
  4. .. contents::
  5. :local:
  6. :depth: 1
  7. What are Task Queues?
  8. =====================
  9. HELLO
  10. What do I need?
  11. ===============
  12. .. sidebar:: Version Requirements
  13. :subtitle: Celery version 2.6 runs on
  14. - Python ❨2.5, 2.6, 2.7, 3.2, 3.3❩
  15. - PyPy ❨1.8, 1.9❩
  16. - Jython ❨2.5, 2.7❩.
  17. This is the last version to support Python 2.5,
  18. and from the next version Python 2.6 or newer is required.
  19. The last version to support Python 2.4 was Celery series 2.2.
  20. *Celery* requires a message broker to send and receive messages,
  21. but this term has been stretched to include everything from
  22. your fridge to financial-grade messaging systems.
  23. *Celery* can run on a single machine, on multiple machines, or even
  24. across datacenters.
  25. Celery is…
  26. ==========
  27. .. topic:: ”
  28. - **Simple**
  29. Celery is easy to use and maintain, and does *not need configuration files*.
  30. It has an active, friendly community you can talk to for support,
  31. including a :ref:`mailing-list <mailing-list>` and and :ref:`IRC
  32. channel <irc-channel>`.
  33. Here's one of the simplest applications you can make:
  34. .. code-block:: python
  35. from celery import Celery
  36. celery = Celery('hello', broker='amqp://guest@localhost//')
  37. @celery.task()
  38. def hello():
  39. return 'hello world'
  40. - **Highly Available**
  41. Workers and clients will automatically retry in the event
  42. of connection loss or failure, and some brokers support
  43. HA in way of *Master/Master* or *Master/Slave* replication.
  44. - **Fast**
  45. A single Celery process can process millions of tasks a minute,
  46. with sub-millisecond round-trip latency (using RabbitMQ,
  47. py-librabbitmq, and optimized settings).
  48. - **Flexible**
  49. Almost every part of *Celery* can be extended or used on its own,
  50. Custom pool implementations, serializers, compression schemes, logging,
  51. schedulers, consumers, producers, autoscalers, broker transports and much more.
  52. .. topic:: It supports
  53. .. hlist::
  54. :columns: 2
  55. - **Brokers**
  56. - :ref:`RabbitMQ <broker-rabbitmq>`
  57. - :ref:`Redis <broker-redis>`,
  58. - :ref:`MongoDB <broker-mongodb>`
  59. - :ref:`Beanstalk <broker-beanstalk>`
  60. - :ref:`CouchDB <broker-couchdb>`
  61. - :ref:`SQLAlchemy <broker-sqlalchemy>`
  62. - :ref:`Django ORM <broker-django>`
  63. - :ref:`Amazon SQS <broker-sqs>`
  64. - and more…
  65. - **Concurrency**
  66. - multiprocessing,
  67. - Eventlet_, gevent_
  68. - threads
  69. - single
  70. - **Result Stores**
  71. - AMQP
  72. - Redis
  73. - memcached
  74. - MongoDB
  75. - SQLAlchemy
  76. - Django ORM
  77. - Apache Cassandra
  78. - **Serialization**
  79. - *pickle*, *json*, *yaml*, *msgpack*.
  80. - Fine-grained serialization settings.
  81. - **Compression**
  82. - *zlib*, *bzip2*, or uncompressed.
  83. - **Crypto**
  84. - Cryptographic message signing.
  85. .. topic:: Features
  86. .. hlist::
  87. :columns: 2
  88. - **Monitoring**
  89. The stream of monitoring events emitted by the worker are used
  90. by built-in and external tools to tell you what your cluster
  91. is doing in real-time.
  92. :ref:`Read more… <guide-monitoring>`.
  93. - **Time Limits & Rate Limits**
  94. You can control how many tasks can be executed per second/minute/hour,
  95. or how long a task can be allowed to run, and this can be set as
  96. a default, for a specific worker or individually for each task type.
  97. :ref:`Read more… <worker-time-limits>`.
  98. - **Autoreloading**
  99. While in development workers can be configured to automatically reload source
  100. code as it changes.
  101. :ref:`Read more… <worker-autoreloading>`.
  102. - **Autoscaling**
  103. Dynamically resizing the worker pool depending on load,
  104. or custom metrics specified by the user, used to limit
  105. memory usage in shared hosting/cloud environment or to
  106. enforce a given quality of service.
  107. :ref:`Read more… <worker-autoscaling>`.
  108. - **Resource Leak Protection**
  109. The :option:`--maxtasksperchild` option is used for user tasks
  110. leaking resources, like memory or file descriptors, that
  111. are simply out of your control.
  112. :ref:`Read more… <worker-maxtasksperchild>`.
  113. - **User Components**
  114. Each worker component can be customized, and additional components
  115. can be defined by the user. The worker is built up using "boot steps" — a
  116. dependency graph enabling fine grained control of the worker's
  117. internals.
  118. .. _`Eventlet`: http://eventlet.net/
  119. .. _`gevent`: http://gevent.org/
  120. .. topic:: I want to ⟶
  121. .. hlist::
  122. :columns: 2
  123. - :ref:`get the return value of a task <task-states>`
  124. - :ref:`use logging from my task <task-logging>`
  125. - :ref:`learn about best practices <task-best-practices>`
  126. - :ref:`create a custom task base class <task-custom-classes>`
  127. - :ref:`add a callback to a group of tasks <chords>`
  128. - :ref:`split a task into several chunks <chunking>`
  129. - :ref:`optimize the worker <guide-optimizing>`
  130. - :ref:`see a list of built-in task states <task-builtin-states>`
  131. - :ref:`create custom task states <custom-states>`
  132. - :ref:`set a custom task name <task-names>`
  133. - :ref:`track when a task starts <task-track-started>`
  134. - :ref:`retry a task when it fails <task-retry>`
  135. - :ref:`get the id of the current task <task-request-info>`
  136. - :ref:`know what queue a task was delivered to <task-request-info>`
  137. - :ref:`see a list of running workers <monitoring-celeryctl>`
  138. - :ref:`purge all messages <monitoring-celeryctl>`
  139. - :ref:`inspect what the workers are doing <monitoring-celeryctl>`
  140. - :ref:`see what tasks a worker has registerd <monitoring-celeryctl>`
  141. - :ref:`migrate tasks to a new broker <monitoring-celeryctl>`
  142. - :ref:`see a list of event message types <event-reference>`
  143. - :ref:`contribute to Celery <contributing>`
  144. - :ref:`learn about available configuration settings <configuration>`
  145. - :ref:`receive email when a task fails <conf-error-mails>`
  146. - :ref:`get a list of people and companies using Celery <res-using-celery>`
  147. - :ref:`write my own remote control command <worker-custom-control-commands>`
  148. - change worker queues at runtime
  149. .. topic:: Jump to ⟶
  150. .. hlist::
  151. :columns: 4
  152. - :ref:`Brokers <brokers>`
  153. - :ref:`Tasks <guide-tasks>`
  154. - :ref:`Calling <guide-calling>`
  155. - :ref:`Workers <guide-workers>`
  156. - :ref:`Monitoring <guide-monitoring>`
  157. - :ref:`Optimizing <guide-optimizing>`
  158. - :ref:`Security <guide-security>`
  159. - :ref:`Routing <guide-routing>`
  160. - :ref:`Configuration Reference <configuration>`
  161. - :ref:`Django <django>`
  162. - :ref:`Contributing <contributing>`
  163. - :ref:`Signals <signals>`
  164. - :ref:`FAQ <faq>`