README.rst 13 KB

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