introduction.txt 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. :Version: 4.1.1 (latentcall)
  2. :Web: http://celeryproject.org/
  3. :Download: https://pypi.python.org/pypi/celery/
  4. :Source: https://github.com/celery/celery/
  5. :Keywords: task, queue, job, async, rabbitmq, amqp, redis,
  6. python, distributed, actors
  7. --
  8. What's a Task Queue?
  9. ====================
  10. Task queues are used as a mechanism to distribute work across threads or
  11. machines.
  12. A task queue's input is a unit of work, called a task, dedicated worker
  13. processes then constantly monitor the queue for new work to perform.
  14. Celery communicates via messages, usually using a broker
  15. to mediate between clients and workers. To initiate a task a client puts a
  16. message on the queue, the broker then delivers the message to a worker.
  17. A Celery system can consist of multiple workers and brokers, giving way
  18. to high availability and horizontal scaling.
  19. Celery is written in Python, but the protocol can be implemented in any
  20. language. In addition to Python there's node-celery_ for Node.js,
  21. and a `PHP client`_.
  22. Language interoperability can also be achieved by using webhooks
  23. in such a way that the client enqueues an URL to be requested by a worker.
  24. .. _node-celery: https://github.com/mher/node-celery
  25. .. _`PHP client`: https://github.com/gjedeer/celery-php
  26. What do I need?
  27. ===============
  28. Celery version 4.0 runs on,
  29. - Python (2.7, 3.4, 3.5)
  30. - PyPy (5.4, 5.5)
  31. This is the last version to support Python 2.7,
  32. and from the next version (Celery 5.x) Python 3.5 or newer is required.
  33. If you're running an older version of Python, you need to be running
  34. an older version of Celery:
  35. - Python 2.6: Celery series 3.1 or earlier.
  36. - Python 2.5: Celery series 3.0 or earlier.
  37. - Python 2.4 was Celery series 2.2 or earlier.
  38. Celery is a project with minimal funding,
  39. so we don't support Microsoft Windows.
  40. Please don't open any issues related to that platform.
  41. *Celery* is usually used with a message broker to send and receive messages.
  42. The RabbitMQ, Redis transports are feature complete,
  43. but there's also experimental support for a myriad of other solutions, including
  44. using SQLite for local development.
  45. *Celery* can run on a single machine, on multiple machines, or even
  46. across datacenters.
  47. Get Started
  48. ===========
  49. If this is the first time you're trying to use Celery, or you're
  50. new to Celery 4.0 coming from previous versions then you should read our
  51. getting started tutorials:
  52. - `First steps with Celery`_
  53. Tutorial teaching you the bare minimum needed to get started with Celery.
  54. - `Next steps`_
  55. A more complete overview, showing more features.
  56. .. _`First steps with Celery`:
  57. http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html
  58. .. _`Next steps`:
  59. http://docs.celeryproject.org/en/latest/getting-started/next-steps.html
  60. Celery is…
  61. =============
  62. - **Simple**
  63. Celery is easy to use and maintain, and does *not need configuration files*.
  64. It has an active, friendly community you can talk to for support,
  65. like at our `mailing-list`_, or the IRC channel.
  66. Here's one of the simplest applications you can make::
  67. from celery import Celery
  68. app = Celery('hello', broker='amqp://guest@localhost//')
  69. @app.task
  70. def hello():
  71. return 'hello world'
  72. - **Highly Available**
  73. Workers and clients will automatically retry in the event
  74. of connection loss or failure, and some brokers support
  75. HA in way of *Primary/Primary* or *Primary/Replica* replication.
  76. - **Fast**
  77. A single Celery process can process millions of tasks a minute,
  78. with sub-millisecond round-trip latency (using RabbitMQ,
  79. py-librabbitmq, and optimized settings).
  80. - **Flexible**
  81. Almost every part of *Celery* can be extended or used on its own,
  82. Custom pool implementations, serializers, compression schemes, logging,
  83. schedulers, consumers, producers, broker transports, and much more.
  84. It supports…
  85. ================
  86. - **Message Transports**
  87. - RabbitMQ_, Redis_, Amazon SQS
  88. - **Concurrency**
  89. - Prefork, Eventlet_, gevent_, single threaded (``solo``)
  90. - **Result Stores**
  91. - AMQP, Redis
  92. - memcached
  93. - SQLAlchemy, Django ORM
  94. - Apache Cassandra, IronCache, Elasticsearch
  95. - **Serialization**
  96. - *pickle*, *json*, *yaml*, *msgpack*.
  97. - *zlib*, *bzip2* compression.
  98. - Cryptographic message signing.
  99. .. _`Eventlet`: http://eventlet.net/
  100. .. _`gevent`: http://gevent.org/
  101. .. _RabbitMQ: https://rabbitmq.com
  102. .. _Redis: https://redis.io
  103. .. _SQLAlchemy: http://sqlalchemy.org
  104. Framework Integration
  105. =====================
  106. Celery is easy to integrate with web frameworks, some of which even have
  107. integration packages:
  108. +--------------------+------------------------+
  109. | `Django`_ | not needed |
  110. +--------------------+------------------------+
  111. | `Pyramid`_ | `pyramid_celery`_ |
  112. +--------------------+------------------------+
  113. | `Pylons`_ | `celery-pylons`_ |
  114. +--------------------+------------------------+
  115. | `Flask`_ | not needed |
  116. +--------------------+------------------------+
  117. | `web2py`_ | `web2py-celery`_ |
  118. +--------------------+------------------------+
  119. | `Tornado`_ | `tornado-celery`_ |
  120. +--------------------+------------------------+
  121. The integration packages aren't strictly necessary, but they can make
  122. development easier, and sometimes they add important hooks like closing
  123. database connections at ``fork``.
  124. .. _`Django`: https://djangoproject.com/
  125. .. _`Pylons`: http://pylonsproject.org/
  126. .. _`Flask`: http://flask.pocoo.org/
  127. .. _`web2py`: http://web2py.com/
  128. .. _`Bottle`: https://bottlepy.org/
  129. .. _`Pyramid`: http://docs.pylonsproject.org/en/latest/docs/pyramid.html
  130. .. _`pyramid_celery`: https://pypi.python.org/pypi/pyramid_celery/
  131. .. _`celery-pylons`: https://pypi.python.org/pypi/celery-pylons
  132. .. _`web2py-celery`: https://code.google.com/p/web2py-celery/
  133. .. _`Tornado`: http://www.tornadoweb.org/
  134. .. _`tornado-celery`: https://github.com/mher/tornado-celery/
  135. .. _celery-documentation:
  136. Documentation
  137. =============
  138. The `latest documentation`_ is hosted at Read The Docs, containing user guides,
  139. tutorials, and an API reference.
  140. .. _`latest documentation`: http://docs.celeryproject.org/en/latest/