README.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. =================================
  2. celery - Distributed Task Queue
  3. =================================
  4. .. image:: http://cloud.github.com/downloads/ask/celery/celery_128.png
  5. :Version: 2.5.0a1
  6. :Web: http://celeryproject.org/
  7. :Download: http://pypi.python.org/pypi/celery/
  8. :Source: http://github.com/ask/celery/
  9. :Keywords: task queue, job queue, asynchronous, rabbitmq, amqp, redis,
  10. python, webhooks, queue, distributed
  11. --
  12. .. _celery-synopsis:
  13. Celery is an open source asynchronous task queue/job queue based on
  14. distributed message passing. It is focused on real-time operation,
  15. but supports scheduling as well.
  16. The execution units, called tasks, are executed concurrently on one or
  17. more worker nodes using multiprocessing, `Eventlet`_ or `gevent`_. Tasks can
  18. execute asynchronously (in the background) or synchronously
  19. (wait until ready).
  20. Celery is used in production systems to process millions of tasks a day.
  21. Celery is written in Python, but the protocol can be implemented in any
  22. language. It can also `operate with other languages using webhooks`_.
  23. The recommended message broker is `RabbitMQ`_, but `limited support`_ for
  24. `Redis`_, `Beanstalk`_, `MongoDB`_, `CouchDB`_ and
  25. databases (using `SQLAlchemy`_ or the `Django ORM`_) is also available.
  26. Celery is easy to integrate with `Django`_, `Pylons`_ and `Flask`_, using
  27. the `django-celery`_, `celery-pylons`_ and `Flask-Celery`_ add-on packages.
  28. .. _`RabbitMQ`: http://www.rabbitmq.com/
  29. .. _`Redis`: http://code.google.com/p/redis/
  30. .. _`SQLAlchemy`: http://www.sqlalchemy.org/
  31. .. _`Django`: http://djangoproject.com/
  32. .. _`Django ORM`: http://djangoproject.com/
  33. .. _`Eventlet`: http://eventlet.net/
  34. .. _`gevent`: http://gevent.org/
  35. .. _`Beanstalk`: http://kr.github.com/beanstalkd/
  36. .. _`MongoDB`: http://mongodb.org/
  37. .. _`CouchDB`: http://couchdb.apache.org/
  38. .. _`Pylons`: http://pylonshq.com/
  39. .. _`Flask`: http://flask.pocoo.org/
  40. .. _`django-celery`: http://pypi.python.org/pypi/django-celery
  41. .. _`celery-pylons`: http://pypi.python.org/pypi/celery-pylons
  42. .. _`Flask-Celery`: http://github.com/ask/flask-celery/
  43. .. _`operate with other languages using webhooks`:
  44. http://ask.github.com/celery/userguide/remote-tasks.html
  45. .. _`limited support`:
  46. http://kombu.readthedocs.org/en/latest/introduction.html#transport-comparison
  47. .. contents::
  48. :local:
  49. .. _celery-overview:
  50. Overview
  51. ========
  52. This is a high level overview of the architecture.
  53. .. image:: http://cloud.github.com/downloads/ask/celery/Celery-Overview-v4.jpg
  54. The broker delivers tasks to the worker nodes.
  55. A worker node is a networked machine running `celeryd`. This can be one or
  56. more machines depending on the workload.
  57. The result of the task can be stored for later retrieval (called its
  58. "tombstone").
  59. .. _celery-example:
  60. Example
  61. =======
  62. You probably want to see some code by now, so here's an example task
  63. adding two numbers:
  64. ::
  65. from celery.task import task
  66. @task
  67. def add(x, y):
  68. return x + y
  69. You can execute the task in the background, or wait for it to finish::
  70. >>> result = add.delay(4, 4)
  71. >>> result.wait() # wait for and return the result
  72. 8
  73. Simple!
  74. .. _celery-features:
  75. Features
  76. ========
  77. +-----------------+----------------------------------------------------+
  78. | Messaging | Supported brokers include `RabbitMQ`_, `Redis`_, |
  79. | | `Beanstalk`_, `MongoDB`_, `CouchDB`_, and popular |
  80. | | SQL databases. |
  81. +-----------------+----------------------------------------------------+
  82. | Fault-tolerant | Excellent configurable error recovery when using |
  83. | | `RabbitMQ`, ensures your tasks are never lost. |
  84. | | scenarios, and your tasks will never be lost. |
  85. +-----------------+----------------------------------------------------+
  86. | Distributed | Runs on one or more machines. Supports |
  87. | | broker `clustering`_ and `HA`_ when used in |
  88. | | combination with `RabbitMQ`_. You can set up new |
  89. | | workers without central configuration (e.g. use |
  90. | | your grandma's laptop to help if the queue is |
  91. | | temporarily congested). |
  92. +-----------------+----------------------------------------------------+
  93. | Concurrency | Concurrency is achieved by using multiprocessing, |
  94. | | `Eventlet`_, `gevent` or a mix of these. |
  95. +-----------------+----------------------------------------------------+
  96. | Scheduling | Supports recurring tasks like cron, or specifying |
  97. | | an exact date or countdown for when after the task |
  98. | | should be executed. |
  99. +-----------------+----------------------------------------------------+
  100. | Latency | Low latency means you are able to execute tasks |
  101. | | *while the user is waiting*. |
  102. +-----------------+----------------------------------------------------+
  103. | Return Values | Task return values can be saved to the selected |
  104. | | result store backend. You can wait for the result, |
  105. | | retrieve it later, or ignore it. |
  106. +-----------------+----------------------------------------------------+
  107. | Result Stores | Database, `MongoDB`_, `Redis`_, `Tokyo Tyrant`, |
  108. | | `Cassandra`, or `AMQP`_ (message notification). |
  109. +-----------------+----------------------------------------------------+
  110. | Webhooks | Your tasks can also be HTTP callbacks, enabling |
  111. | | cross-language communication. |
  112. +-----------------+----------------------------------------------------+
  113. | Rate limiting | Supports rate limiting by using the token bucket |
  114. | | algorithm, which accounts for bursts of traffic. |
  115. | | Rate limits can be set for each task type, or |
  116. | | globally for all. |
  117. +-----------------+----------------------------------------------------+
  118. | Routing | Using AMQP's flexible routing model you can route |
  119. | | tasks to different workers, or select different |
  120. | | message topologies, by configuration or even at |
  121. | | runtime. |
  122. +-----------------+----------------------------------------------------+
  123. | Remote-control | Worker nodes can be controlled from remote by |
  124. | | using broadcast messaging. A range of built-in |
  125. | | commands exist in addition to the ability to |
  126. | | easily define your own. (AMQP/Redis only) |
  127. +-----------------+----------------------------------------------------+
  128. | Monitoring | You can capture everything happening with the |
  129. | | workers in real-time by subscribing to events. |
  130. | | A real-time web monitor is in development. |
  131. +-----------------+----------------------------------------------------+
  132. | Serialization | Supports Pickle, JSON, YAML, or easily defined |
  133. | | custom schemes. One task invocation can have a |
  134. | | different scheme than another. |
  135. +-----------------+----------------------------------------------------+
  136. | Tracebacks | Errors and tracebacks are stored and can be |
  137. | | investigated after the fact. |
  138. +-----------------+----------------------------------------------------+
  139. | UUID | Every task has an UUID (Universally Unique |
  140. | | Identifier), which is the task id used to query |
  141. | | task status and return value. |
  142. +-----------------+----------------------------------------------------+
  143. | Retries | Tasks can be retried if they fail, with |
  144. | | configurable maximum number of retries, and delays |
  145. | | between each retry. |
  146. +-----------------+----------------------------------------------------+
  147. | Task Sets | A Task set is a task consisting of several |
  148. | | sub-tasks. You can find out how many, or if all |
  149. | | of the sub-tasks has been executed, and even |
  150. | | retrieve the results in order. Progress bars, |
  151. | | anyone? |
  152. +-----------------+----------------------------------------------------+
  153. | Made for Web | You can query status and results via URLs, |
  154. | | enabling the ability to poll task status using |
  155. | | Ajax. |
  156. +-----------------+----------------------------------------------------+
  157. | Error Emails | Can be configured to send emails to the |
  158. | | administrators when tasks fails. |
  159. +-----------------+----------------------------------------------------+
  160. .. _`clustering`: http://www.rabbitmq.com/clustering.html
  161. .. _`HA`: http://www.rabbitmq.com/pacemaker.html
  162. .. _`AMQP`: http://www.amqp.org/
  163. .. _`Stomp`: http://stomp.codehaus.org/
  164. .. _`Tokyo Tyrant`: http://tokyocabinet.sourceforge.net/
  165. .. _celery-documentation:
  166. Documentation
  167. =============
  168. The `latest documentation`_ with user guides, tutorials and API reference
  169. is hosted at Github.
  170. .. _`latest documentation`: http://ask.github.com/celery/
  171. .. _celery-installation:
  172. Installation
  173. ============
  174. You can install Celery either via the Python Package Index (PyPI)
  175. or from source.
  176. To install using `pip`,::
  177. $ pip install Celery
  178. To install using `easy_install`,::
  179. $ easy_install Celery
  180. .. _celery-installing-from-source:
  181. Downloading and installing from source
  182. --------------------------------------
  183. Download the latest version of Celery from
  184. http://pypi.python.org/pypi/celery/
  185. You can install it by doing the following,::
  186. $ tar xvfz celery-0.0.0.tar.gz
  187. $ cd celery-0.0.0
  188. $ python setup.py build
  189. # python setup.py install # as root
  190. .. _celery-installing-from-git:
  191. Using the development version
  192. -----------------------------
  193. You can clone the repository by doing the following::
  194. $ git clone git://github.com/ask/celery.git
  195. .. _getting-help:
  196. Getting Help
  197. ============
  198. .. _mailing-list:
  199. Mailing list
  200. ------------
  201. For discussions about the usage, development, and future of celery,
  202. please join the `celery-users`_ mailing list.
  203. .. _`celery-users`: http://groups.google.com/group/celery-users/
  204. .. _irc-channel:
  205. IRC
  206. ---
  207. Come chat with us on IRC. The `#celery`_ channel is located at the `Freenode`_
  208. network.
  209. .. _`#celery`: irc://irc.freenode.net/celery
  210. .. _`Freenode`: http://freenode.net
  211. .. _bug-tracker:
  212. Bug tracker
  213. ===========
  214. If you have any suggestions, bug reports or annoyances please report them
  215. to our issue tracker at http://github.com/ask/celery/issues/
  216. .. _wiki:
  217. Wiki
  218. ====
  219. http://wiki.github.com/ask/celery/
  220. .. _contributing-short:
  221. Contributing
  222. ============
  223. Development of `celery` happens at Github: http://github.com/ask/celery
  224. You are highly encouraged to participate in the development
  225. of `celery`. If you don't like Github (for some reason) you're welcome
  226. to send regular patches.
  227. Be sure to also read the `Contributing to Celery`_ section in the
  228. documentation.
  229. .. _`Contributing to Celery`: http://ask.github.com/celery/contributing.html
  230. .. _license:
  231. License
  232. =======
  233. This software is licensed under the `New BSD License`. See the ``LICENSE``
  234. file in the top distribution directory for the full license text.
  235. .. # vim: syntax=rst expandtab tabstop=4 shiftwidth=4 shiftround