Introduction to Celery in Django?

Introduction to Celery in Django?

Celery, keeps you healthy if you include it in your diet.

Note: If you are looking for a Full Stack Developer (Django+React), then connect with me on LinkedIn or contact me through my portfolio.


Celery is an asynchronous task queue in Django, basically used for queuing time-consuming tasks. Let me give you a real world use case of Celery.


Let’s say you have an application where you want to send a Welcome Email to the user after Sign Up, if you perform this operation synchronously with Django, it will be going to hold the HTTP request execution until the email is sent.

Now to solve this problem, we can transfer this task burden to a task queue such as Celery, so whenever a user Sign Up in your application, your HTTP request will continue the process, and then it will pass the task to Celery instance, which is running in a different server (service).

Task Broker:

Now, Celery is not capable of executing those asynchronous task all by itself, because Celery is just a service running in your server.

Whenever a task comes to Celery, it stores the task with a unique ID inside a persistent storage called Task Broker.

Now, the job of this Task Broker is to assign a task ID to any message that comes, and then forward it to Celery for further processing.

We do not use relation databases because these are slow, on the other hand task brokers are fast, reliable, concurrency enabled.

Two very popular task brokers are RabbitMQ and Redis.


Installing Celery in a Django project is pretty easy:

pip install celery

That’s it for today, in the next blog, we will learn how to use Celery in a Django project and how to execute it asynchronously.

For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.

Did you find this article valuable?

Support Dev.Junction by becoming a sponsor. Any amount is appreciated!