Celery是一个简单、灵活且可靠的,处理大量消息的分布式系统
专注于实时处理的异步任务队列
同时也支持任务调度
Celery的架构由三部分组成,消息中间件(message broker),任务执行单元(worker)和任务执行结果存储(task result store)组成。
Celery本身不提供消息服务,但是可以方便的和第三方提供的消息中间件集成。包括,RabbitMQ, Redis等等
Worker是Celery提供的任务执行的单元,worker并发的运行在分布式的系统节点中。
Task result store用来存储Worker执行的任务的结果,Celery支持以不同方式存储任务的结果,包括AMQP, redis等
| Celery version 4.0 runs on |
| Python ❨2.7, 3.4, 3.5❩ |
| PyPy ❨5.4, 5.5❩ |
| This is the last version to support Python 2.7, and from the next version (Celery 5.x) Python 3.5 or newer is required. |
| If you’re running an older version of Python, you need to be running an older version of Celery: |
| Python 2.6: Celery series 3.1 or earlier. |
| Python 2.5: Celery series 3.0 or earlier. |
| Python 2.4 was Celery series 2.2 or earlier. |
| Celery is a project with minimal funding, so we don’t support Microsoft Windows. Please don’t open any issues related to that platform. |
异步任务:将耗时操作任务提交给Celery去异步执行,比如发送短信/邮件、消息推送、音视频处理等等
定时任务:定时执行某件事情,比如每天数据统计
| pip install celery |
| 消息中间件:RabbitMQ/Redis |
| app=Celery('任务名',backend='xxx',broker='xxx') |