I work for a travel company where we need to send periodic mails to our teams .
Since now I have been using django management commands and running them using crontabs. I was reading about what celery can do, but I am finding it really hard to understand why should I use celery ?
Also since it would be another addition to my django project and also to the database ,does it slow down the performance ?
Basically, a Django management command is built from a class named Command which inherits from BaseCommand. 1) help: It tells what actually the command does. Run the following command and see the help. python manage.py stats --help.
Celery is a task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well. The execution units, called tasks, are executed concurrently on a single or more worker servers.
Celery is an open-source Python library which is used to run the tasks asynchronously. It is a task queue that holds the tasks and distributes them to the workers in a proper manner. It is primarily focused on real-time operation but also supports scheduling (run regular interval tasks).
The "shared_task" decorator allows creation of Celery tasks for reusable apps as it doesn't need the instance of the Celery app. It is also easier way to define a task as you don't need to import the Celery app instance.
I don't think you should use celery, Cron still sounds fine to me in your case, but you might want to give Celery a try.
To me, Celery is a Python module for [asynchronous] [distributed] task queues. It allows you to dispatch lengthy tasks to multiple processes running on multiple machines (but one process on one machine is still fine). When you need to do something that takes time (like generate thumbnails, speak to an external API or generate complex reports), you can use Celery to do this in the background without blocking HTTP request for your user.
Some advantages of Celery over crontab:
Some disadvantages of Celery:
And also, if it's just about sending e-mails, you could consider using a paid service such as Postmark (I am not affiliated to them), which will handle e-mail throttling for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With