Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to design chat based application with nodejs, redis and mongodb?

We have an application for iOS which has a chat feature. Currently it works with long poll. And now we are trying to modify it to work with sockets. When it comes to socket, we have started for a research and it seems that one of the best option is using nodejs with socket.io. Then we have used redis pub/sub to manage the message delivery and storage.

After a few researching on redis, the recommended usage suggests the stored data should fit on memory. But, we have a little big database. We would like to store the whole chat history. So we have started to plan to use redis as a cache database, which will store the online user's chat history (may be not whole of them) and write the actual conversation after getting offline from redis to mongodb/simpledb (or instantly both of them).

So as a summary, we are about to decide to use nodejs and redis pub/sub to deliver messages, redis as a cache database, and mongodb to store the whole conversation.

What do you think about the design? Is this acceptable? Or, if there is a better way you can suggest, can you please explain a little more?

Thanks in advance.

like image 606
Ali Ersöz Avatar asked Oct 24 '22 03:10

Ali Ersöz


1 Answers

For a chat system, you're thinking big. If you think you're going to reach a million users then go for it. Consider also availability - how will your system deal with failure of a machine?

like image 81
Michael Slade Avatar answered Oct 26 '22 23:10

Michael Slade