Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Socket.IO with RabbitMQ?

I'm currently using Socket.IO with redis store.

And I'm using Room feature with it.

So I'm totally okay with Room join (subscribe)

and Leave (unsubscribe) with Socket.IO.

I just see this page

http://www.rabbitmq.com/blog/2010/11/12/rabbitmq-nodejs-rabbitjs/

And I have found that some people are using Socket.IO with rabbitMQ.

Why using Socket.IO alone is not good enough?

Is there any good reason to use Socket.IO with rabbitMQ?

like image 580
jwchang Avatar asked Mar 22 '12 15:03

jwchang


1 Answers

I just used rabbitMQ with socket.io for a totally different reason than in the accepted answer. It wasn't that relevant in 2012, that's why I'm updating here.

I'm using a docker swarm deployment of a chat application with scalability and high availability. I have three replicas of the chat application (which uses socket.io) running in the cluster. The swarm cluster automatically load-balances the incoming requests and at any given time a client might get connected to any of the three replicas of the application.

With this scenario, it gets really necessary to sync the WebSocket responses in the replicas of the application because two clients connected to two different instances of the application wouldn't get each other's messages because they've been connected to different WebSockets.

This is where rabbitMQ intervenes. It syncs all the instances of the application and whenever a message is pushed from a WebSocket on a replica, it gets pushed by all replicas.

enter image description here

Complete details of the project have been given here. This is a potential use case of socket.io and rabbitMQ use in conjunction. This goes for any application using socket.io in a distributed environment with high availability and scalability.

like image 110
Saqib Ahmed Avatar answered Oct 09 '22 16:10

Saqib Ahmed