Thursday, 26 March 2020

Reddis , RabitMQ , celery , mongoDB -- confusing world for a newbie


So, if you have searched something for distributed task queue, or asynchronous task or even "how to send email from Django" you would have encountered above words in title.

Yes, they can do your job. really.

But do you need all of them to do your Job (like sending email from Django)?? No.

Even with just Reddis , RabitMQ or mongoDB you can achieve that. (celery always need a message broker i.e someone to command the task and then celery can do rest of the thing. ).

So , What are all these things ????

First let's understand Reddis vs MongoDB.

Well both are NoSQL database.But there are some key differences between them , which makes them chamipion of their domain:

1) Reddis is an "In-memory" "NoSQL" "Key-Value Store/Database" with some capability of a "Message queue".

"In-memory" means it is stored in RAM by default , that is why it is very fast , useful when your data beign updated at very high-speed for example if you want to store stock market data and do some runtime analysis on them.
But with reddis your data base size will be limited by the RAM you have availible.

It can be also used as "Message queue" and that is why it is compared many times with RabitMQ. you will find many questions regarding this on stack overflow.

2 ) MongoDB is "by default stored on disk" , "NoSQL" , "document store/Database" , with no official "Message queue" stuff.

Disk based means database will be stored in your SSD or Hard disk.
Although it will make it slow, but there are many comparison article which says mongoDB is at par with Reddis in terms of speed.

But wait , from mongoDB 3.6 onwards , mongoDB supports change streams. By using change streams you can implement similar functionality like message queue, interested ??
Read this article :

https://api.mongodb.com/python/current/api/pymongo/change_stream.html >

All clear upto this ???


3) RabitMQ is a distributed message queue, and it is not a full-fledged database.

Message queue is needed when you have one or more producer of tasks and you want them to be consumed by consumer in a distributed manner, and you don't want to take tension.
you can read more about rabitMQ on their official site. just search like rabitMQ python tutorial.


4) So what's celery??

Celery is something if you combine with rabitMQ , than it can even further reduce your tension.
Celery also supports reddis, but believe me you should be focusing RabitMQ + celery stuff.


So, that's it people. I know you might not be enhancing your knowledge much from this dumb article, but this is what I wanted to document.

1 comment:

  1. very useful knowledge..
    looking forward to learning more from you.....
    thank you....

    ReplyDelete