Thursday, February 12, 2015

Basics of Celery

Hello fellow Ingeneers.

I just would like to share to you what I've learned from tackling Celery.


By definition, Celery is a Distributed Task Queue. Its job is basically, to execute tasks. But what makes Celery great is that it is asynchronous in nature, meaning, it can perform various tasks in a separate process, without interfering with the main processes. Isn't it great or what?

Running tasks on Celery can either be Real-time or Scheduled. By scheduled, meaning, you can control your tasks as to when it will be executed by settings various time measurements such as day, week, seconds, or even an actual date. 

Celery is based on distributed message passing. It use messages to relay tasks to its workers. In order for Celery to be able to relay messages, message brokers are needed.

Message brokers are basically responsible for passing messages between your application and the Celery worker. Many message brokers are available, but RabbitMQ and Redis are the more popular ones, and widely used.

Basic Celery configuration: celery.py



either in your settings.py or a separate file (e.g. celeryconfig.py)



Creating tasks: tasks.py


And now, running the worker process



There you go, the basics of Celery. There are still a lot of cool features that you can do and discover with Celery. I hope this helps you get started.

Here is a link to my Celery Presentation if you'd like to view more resources and tutorial links.


Thanks.

No comments:

Post a Comment