README.rst 14 KB

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