Lets say I have multiple websocket servers that maintain many connections to clients to send updates. These websocket servers will be pulling said updates from a rabbitmq broker, and broadcasting them to all relevant clients who happen to be on a page that needs an update.

My question is how can all clients who are on page[x] get an update for it if they are split up across multiple websocket servers? WS-server-A will recieve an update and forward it out to all its clients on page[x], but whate about the clients connected to WS-server-b who has clients on the same page?

(edited below to add more details)

The way I'm imagining this scenario is like so:

For an imaginary forum, we have a multi-threaded web server that does page rendering and responds to api calls. When someone saves a post on a topic, the web server saves the post to the db, then passes the post off to rabbitmq.

Rabbitmq forwards this post to the relevant exchange (say, 'new-posts'. There are also other exchanges: 'new-topics', 'alerts', etc), where the websocket server picks it up, examines the "header" and forwards the post to all users who are on the relevant page.

  • Does WS-Server-B not get the updates? Or are you asking how can B also get the updates? Aug 3, 2016 at 21:20
  • @ShaneAndrie Yes, I'm asking how both can get them so that clients on page[x] connected to server-b can receive the updates they need as well.
    – Jaigus
    Aug 3, 2016 at 21:44

2 Answers 2


What probably happens right now is that some messages are processed by server A, and never delivered to B, and some are processed by B, but A never receives them. This is because you haven't specified the exchange: the default one is the direct exchange, meaning that messages are sent to one of the queues at a time, using round robin.

In order for multiple servers to receive the message, you may use the fanout exchange routing. With this type of routing, the same message will be routed to every queue.

The exchange routing type is specified when you create the exchange.

You can find additional information about different types of exchanges on the official RabbitMQ website.


The scenario you're talking about is best addressed using the Pub-sub messaging pattern. In RabbitMQ this is supported by the Fanout Exchange type. Check out the Pub-Sub tutorial on the Rabbit Website for a walkthrough of creating a fanout exchange.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.