123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- =============================
- Introduction to Task Queues
- =============================
- .. contents::
- :local:
- :depth: 1
- What are Task Queues?
- =====================
- HELLO
- What do I need?
- ===============
- .. sidebar:: Version Requirements
- :subtitle: Celery version 2.6 runs on
- - Python ❨2.5, 2.6, 2.7, 3.2, 3.3❩
- - PyPy ❨1.8, 1.9❩
- - Jython ❨2.5, 2.7❩.
- This is the last version to support Python 2.5,
- and from the next version Python 2.6 or newer is required.
- The last version to support Python 2.4 was Celery series 2.2.
- *Celery* requires a message broker to send and receive messages,
- but this term has been stretched to include everything from
- your fridge to financial-grade messaging systems.
- *Celery* can run on a single machine, on multiple machines, or even
- across datacenters.
- Celery is…
- ==========
- .. topic:: ”
- - **Simple**
- Celery is easy to use and maintain, and does *not need configuration files*
- It has an active, friendly community you can talk to for support,
- including a :ref:`mailing-list <mailing-list>` and and :ref:`IRC
- channel <irc-channel>`.
- Here's one of the simplest applications you can make:
- .. code-block:: python
- from celery import Celery
- celery = Celery("hello", broker="amqp://guest@localhost//")
- @celery.task()
- def hello():
- return "hello world"
- - **Highly Available**
- Workers and clients will automatically retry in the event
- of connection loss or failure, and some brokers support
- HA in way of *Master/Master* or -- *Master/Slave* replication.
- - **Fast**
- A single Celery process can process millions of tasks a minute,
- with sub-millisecond round-trip latency (using RabbitMQ,
- py-librabbitmq, and optimized settings).
- - **Flexible**
- Almost every part of *Celery* can be extended or used on its own,
- Custom pool implementations, serializers, compression schemes, logging,
- schedulers, consumers, producers, autoscalers, broker transorts and much more.
- .. topic:: It supports
- .. hlist::
- :columns: 2
- - **Brokers**
- - :ref:`RabbitMQ <broker-rabbitmq>`, :ref:`Redis <broker-redis>`,
- - :ref:`MongoDB <broker-mongodb>`, :ref:`Beanstalk <broker-beanstalk>`,
- - :ref:`CouchDB <broker-couchdb>`, :ref:`SQLAlchemy <broker-sqlalchemy>`,
- - :ref:`Django ORM <broker-django>`, and more…
- - **Concurrency**
- - multiprocessing,
- - Eventlet_, gevent_
- - threads
- - single
- - **Result Stores**
- - AMQP, Redis
- - memcached, MongoDB,
- - SQLAlchemy/Django ORM,
- - Apache Cassandra.
- - **Serialization & Compression**
- - *pickle*, *json*, *yaml*, *msgpack*.
- - *zlib*, *bzip2*, or uncompressed.
- - Cryptographic message signing.
- - Fine-grained serialization settings.
- .. topic:: Features
- .. hlist::
- :columns: 2
- - **Monitoring**
- The stream of monitoring events emit by the worker are used
- by built-in and external tools to tell you what your cluster
- is doing in real-time.
- :ref:`Read more… <guide-monitoring>`.
- - **Time Limits & Rate Limits**
- You can control how many tasks can be executed per second/minute/hour,
- or how long a task can be allowed to run, and this can be set as
- a default, for a specific worker or individually for each task type.
- :ref:`Read more… <worker-time-limits>`.
- - **Autoreloading**
- While in development workers can be configured to automatically reload source
- code as it changes.
- :ref:`Read more… <worker-autoreloading>`.
- - **Autoscaling**
- Dynamically resizing the worker pool depending on load,
- or custom metrics specified by the user, used to limit
- memory usage in shared hosting/cloud environment or to
- enforce a given quality of service.
- :ref:`Read more… <worker-autoscaling>`.
- - **Resource Leak Protection**
- The :option:`--maxtasksperchild` option is used for user tasks
- leaking resources, like memory or file descriptors, that
- are out simply out of your control.
- :ref:`Read more… <worker-maxtasksperchild>`.
- - **User Components**
- Each worker component can be customized, and additional components
- can be defined by the user. The worker is built up using "boot steps" — a
- dependency graph enabling fine grained control of the workers
- internals.
- .. _`Eventlet`: http://eventlet.net/
- .. _`gevent`: http://gevent.org/
- .. topic:: I want to ⟶
- .. hlist::
- :columns: 2
- - :ref:`get the return value of a task <task-states>`
- - :ref:`use logging from my task <task-logging>`
- - :ref:`learn about best practices <task-best-practices>`
- - :ref:`create a custom task base class <task-custom-classes>`
- - :ref:`add a callback to a group of tasks <chords-ov>`
- - :ref:`split a task into several chunks <chunking-ov>`
- - :ref:`optimize the worker <guide-optimizing>`
- - :ref:`see a list of built-in task states <task-builtin-states>`
- - :ref:`create custom task states <custom-states>`
- - :ref:`set a custom task name <task-names>`
- - :ref:`track when a task starts <task-track-started>`
- - :ref:`retry a task when it fails <task-retry>`
- - :ref:`get the id of the current task <task-request-info>`
- - :ref:`know what queue a task was delivered to <task-request-info>`
- - :ref:`see a list of running workers <monitoring-celeryctl>`
- - :ref:`purge all messages <monitoring-celeryctl>`
- - :ref:`inspect what the workers are doing <monitoring-celeryctl>`
- - :ref:`see what tasks a worker has registerd <monitoring-celeryctl>`
- - :ref:`migrate tasks to a new broker <monitoring-celeryctl>`
- - :ref:`see a list of event message types <event-reference>`
- - :ref:`contribute to Celery <contributing>`
- - :ref:`learn about available configuration settings <configuration>`
- - :ref:`receive email when a task fails <conf-error-mails>`
- - :ref:`get a list of people and companies using Celery <res-using-celery>`
- - :ref:`write my own remote control command <worker-custom-control-commands>`
- - change worker queues at runtime
- .. topic:: Jump to ⟶
- .. hlist::
- :columns: 4
- - :ref:`Brokers <brokers>`
- - :ref:`Tasks <guide-tasks>`
- - :ref:`Calling <guide-calling>`
- - :ref:`Workers <guide-workers>`
- - :ref:`Monitoring <guide-monitoring>`
- - :ref:`Optimizing <guide-optimizing>`
- - :ref:`Security <guide-security>`
- - :ref:`Routing <guide-routing>`
- - :ref:`Configuration Reference <configuration>`
- - :ref:`Django <django>`
- - :ref:`Contributing <contributing>`
- - :ref:`Signals <signals>`
- - :ref:`FAQ <faq>`
|