toonin icon indicating copy to clipboard operation
toonin copied to clipboard

Explore and integrate Redis to keep track of rooms

Open alir128 opened this issue 4 years ago • 6 comments

It might be a good idea to add redis to store rooms on memory on the backend.

https://www.brainvire.com/can-redis-help-improving-node-js-app-performance/

alir128 avatar Apr 25 '20 05:04 alir128

I was looking into this a while back. I'll research a bit more about it and try and get it working

Lakshya2610 avatar Apr 25 '20 07:04 Lakshya2610

https://aws.amazon.com/blogs/database/how-to-build-a-chat-application-with-amazon-elasticache-for-redis/

alir128 avatar Apr 25 '20 07:04 alir128

@ArsalaBangash I integrated socket.io-redis recently in a project. So, I can integrate it into toonin's backend (if you still wanna do it). But we would need a redis database to make use of socket.io-redis. We can either host the database ourselves or use Redis Labs' free online cloud service (It has a free limit of 30 MB if I remember correctly).

You can check out all the options here: https://redis.io/download

If we want to deploy the database ourselves, we can get Docker image from the link above and get it running. I have personally used the free version of the cloud service, and it seems to work well. And it would be the easiest and fastest way to implement this.

Lakshya2610 avatar Aug 24 '20 06:08 Lakshya2610

@Lakshya2610 https://elements.heroku.com/addons/heroku-redis we can just use this as an add-on with our current deployment, this gives 25MB storage which should be enough.

alir128 avatar Aug 24 '20 06:08 alir128

Yeah, it should be fine. Can you set that up and send me the credentials for the redis host. I need these values and I can get it running image

Lakshya2610 avatar Aug 24 '20 06:08 Lakshya2610

So, sorry for the late update. I have been really busy and this totally slipped from my mind. I tried integrating socket.io-redis on the backend but I realized that there is a problem. We can offload the socket rooms to the redis server to allow for scaling, but the socket rooms aren't the only things that we need to offload. Our backend relies on other data structures and classes to manage rooms and clients, so we would need to offload those to a database or a common server as well (could use MongoDB for this). @ArsalaBangash @alir128 What do you guys think about this? Keep in mind that adding MongoDB on the backend would require major changes on the backend.

Lakshya2610 avatar Oct 27 '20 19:10 Lakshya2610