intro.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. [Q: What's the purpose of the '--' before Master/Slave?]
  45. - **Fast**
  46. A single Celery process can process millions of tasks a minute,
  47. with sub-millisecond round-trip latency (using RabbitMQ,
  48. py-librabbitmq, and optimized settings).
  49. - **Flexible**
  50. Almost every part of *Celery* can be extended or used on its own,
  51. Custom pool implementations, serializers, compression schemes, logging,
  52. schedulers, consumers, producers, autoscalers, broker transorts and much more.
  53. .. topic:: It supports
  54. .. hlist::
  55. :columns: 2
  56. - **Brokers**
  57. - :ref:`RabbitMQ <broker-rabbitmq>`
  58. - :ref:`Redis <broker-redis>`,
  59. - :ref:`MongoDB <broker-mongodb>`
  60. - :ref:`Beanstalk <broker-beanstalk>`
  61. - :ref:`CouchDB <broker-couchdb>`
  62. - :ref:`SQLAlchemy <broker-sqlalchemy>`
  63. - :ref:`Django ORM <broker-django>`
  64. - :ref:`Amazon SQS <broker-sqs>`
  65. - and more…
  66. - **Concurrency**
  67. - multiprocessing,
  68. - Eventlet_, gevent_
  69. - threads
  70. - single
  71. - **Result Stores**
  72. - AMQP
  73. - Redis
  74. - memcached
  75. - MongoDB
  76. - SQLAlchemy
  77. - Django ORM
  78. - Apache Cassandra
  79. - **Serialization**
  80. - *pickle*, *json*, *yaml*, *msgpack*.
  81. - Fine-grained serialization settings.
  82. - **Compression**
  83. - *zlib*, *bzip2*, or uncompressed.
  84. - **Crypto**
  85. - Cryptographic message signing.
  86. .. topic:: Features
  87. .. hlist::
  88. :columns: 2
  89. - **Monitoring**
  90. The stream of monitoring events emitted by the worker are used
  91. by built-in and external tools to tell you what your cluster
  92. is doing in real-time.
  93. :ref:`Read more… <guide-monitoring>`.
  94. - **Time Limits & Rate Limits**
  95. You can control how many tasks can be executed per second/minute/hour,
  96. or how long a task can be allowed to run, and this can be set as
  97. a default, for a specific worker or individually for each task type.
  98. :ref:`Read more… <worker-time-limits>`.
  99. - **Autoreloading**
  100. While in development workers can be configured to automatically reload source
  101. code as it changes.
  102. :ref:`Read more… <worker-autoreloading>`.
  103. - **Autoscaling**
  104. Dynamically resizing the worker pool depending on load,
  105. or custom metrics specified by the user, used to limit
  106. memory usage in shared hosting/cloud environment or to
  107. enforce a given quality of service.
  108. :ref:`Read more… <worker-autoscaling>`.
  109. - **Resource Leak Protection**
  110. The :option:`--maxtasksperchild` option is used for user tasks
  111. leaking resources, like memory or file descriptors, that
  112. are simply out of your control.
  113. :ref:`Read more… <worker-maxtasksperchild>`.
  114. - **User Components**
  115. Each worker component can be customized, and additional components
  116. can be defined by the user. The worker is built up using "boot steps" — a
  117. dependency graph enabling fine grained control of the worker's
  118. internals.
  119. .. _`Eventlet`: http://eventlet.net/
  120. .. _`gevent`: http://gevent.org/
  121. .. topic:: I want to ⟶
  122. .. hlist::
  123. :columns: 2
  124. - :ref:`get the return value of a task <task-states>`
  125. - :ref:`use logging from my task <task-logging>`
  126. - :ref:`learn about best practices <task-best-practices>`
  127. - :ref:`create a custom task base class <task-custom-classes>`
  128. - :ref:`add a callback to a group of tasks <chords>`
  129. - :ref:`split a task into several chunks <chunking>`
  130. - :ref:`optimize the worker <guide-optimizing>`
  131. - :ref:`see a list of built-in task states <task-builtin-states>`
  132. - :ref:`create custom task states <custom-states>`
  133. - :ref:`set a custom task name <task-names>`
  134. - :ref:`track when a task starts <task-track-started>`
  135. - :ref:`retry a task when it fails <task-retry>`
  136. - :ref:`get the id of the current task <task-request-info>`
  137. - :ref:`know what queue a task was delivered to <task-request-info>`
  138. - :ref:`see a list of running workers <monitoring-celeryctl>`
  139. - :ref:`purge all messages <monitoring-celeryctl>`
  140. - :ref:`inspect what the workers are doing <monitoring-celeryctl>`
  141. - :ref:`see what tasks a worker has registerd <monitoring-celeryctl>`
  142. - :ref:`migrate tasks to a new broker <monitoring-celeryctl>`
  143. - :ref:`see a list of event message types <event-reference>`
  144. - :ref:`contribute to Celery <contributing>`
  145. - :ref:`learn about available configuration settings <configuration>`
  146. - :ref:`receive email when a task fails <conf-error-mails>`
  147. - :ref:`get a list of people and companies using Celery <res-using-celery>`
  148. - :ref:`write my own remote control command <worker-custom-control-commands>`
  149. - change worker queues at runtime
  150. [Q: is there a reference for this?]
  151. .. topic:: Jump to ⟶
  152. .. hlist::
  153. :columns: 4
  154. - :ref:`Brokers <brokers>`
  155. - :ref:`Tasks <guide-tasks>`
  156. - :ref:`Calling <guide-calling>`
  157. - :ref:`Workers <guide-workers>`
  158. - :ref:`Monitoring <guide-monitoring>`
  159. - :ref:`Optimizing <guide-optimizing>`
  160. - :ref:`Security <guide-security>`
  161. - :ref:`Routing <guide-routing>`
  162. - :ref:`Configuration Reference <configuration>`
  163. - :ref:`Django <django>`
  164. - :ref:`Contributing <contributing>`
  165. - :ref:`Signals <signals>`
  166. - :ref:`FAQ <faq>`