異步任務隊列:celery

jopen 11年前發布 | 39K 次閱讀 消息系統 Celery

celery是一個異步任務隊列/基于分布式消息傳遞的作業隊列。它側重于實時操作,但對調度支持也很好。

celery用于生產系統每天處理數以百萬計的任務。
687474703a2f2f636c6f75642e6769746875622e636f6d2f646f776e6c6f6164732f63656c6572792f63656c6572792f63656c6572795f3132382e706e67.png

celery是用Python編寫的,但該協議可以在任何語言實現。它也可以與其他語言通過webhooks實現。

建議的消息代理RabbitMQ的,但提供有限支持Redis, Beanstalk, MongoDB, CouchDB, ,和數據庫(使用SQLAlchemy的或Django的 ORM) 。

Celery is...

  • 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 mailing-list and and an IRC channel.

    Here's one of the simplest applications you can make:

    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 transports and much more.

It supports...

  • Brokers

  • Concurrency

  • Result Stores

    • AMQP, Redis
    • memcached, MongoDB
    • SQLAlchemy, Django ORM
    • Apache Cassandra, IronCache
  • Serialization

    • pickle, json, yaml, msgpack.
    • zlib, bzip2 compression.
    • Cryptographic message signing.

Framework Integration

Celery is easy to integrate with web frameworks, some of which even have integration packages:

Django django-celery
Pyramid pyramid_celery
Pylons celery-pylons
Flask not needed
web2py web2py-celery
Tornado tornado-celery

The integration packages are not strictly necessary, but they can make development easier, and sometimes they add important hooks like closing database connections at fork.

項目主頁:http://www.baiduhome.net/lib/view/home/1372152459838

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!