intro.rst 7.1 KB

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