jwchang
jwchang

Reputation: 10864

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?

Upvotes: 10

Views: 18701

Answers (3)

Saqib Ahmed
Saqib Ahmed

Reputation: 1125

I just used rabbitMQ with socket.io for a different reason than in the accepted answer. It wasn't that relevant in 2012, that's why I'm updating it 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 comes into the picture. 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.

docker swarm deployment

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.

Upvotes: 6

Marek
Marek

Reputation: 3509

Take a look at SockJS http://sockjs.org .

  1. It's made by the RabbitMQ team
  2. It's simpler than Socket.io
  3. There's an erlang server for SockJS

Apart from that, there is an experimental project within RabbitMQ team that intends to provide a SockJS plugin for RabbitMQ.

Upvotes: 5

Steve Martin
Steve Martin

Reputation: 1642

SocketIO is a browser --> server transport mechanism whereas RabbitMQ is a server --> server message bus.

The two can be implemented together to create a very responsive system in scenarios where a user journey consists of a message starting life on a browser and ending up in, say, some persistence layer (such as a database).

A message would be transported to the web server via socketIO and then, instead of the web server being responsible for persisting the message, it would drop it on a Rabbit queue and leave some other process responsible for persisting it. This way, the web server is free to return to its web serving responsibilities and, crucially, lessening its load.

Upvotes: 20

Related Questions