The back-end service I want to build has the following functional requirements:
Users can create rooms in which other invited users can share content.
One user's change to a room they're in must be instantly notified to other users in it.
Assuming sticky sessions are set up and one user will always send requests to one instance, the question is how to manage notifying other users (on other instances) when an event happens?
My idea was to have a message broker to communicate between all instances. The flow would be something like this:
Whenever a user is created on an instance, make the instance listen to the topic of the user's id.
Whenever a message (containing sender's id, room id, room owner's id, data) comes to an instance, publish to the message broker on the topic of the owner's id.
The instance that listens to the owner id gets the message, retrieves the room info, and publishes the message yet again to all the users in it.
However I feel like this causes a lot of overhead and there most probably are better ways to deal with this. Would it be better to have room ids used as topics? Thoughts?