Lets have an application that has real-time chat feature. The chat requires websockets in order to function real-time.
Now imagine we have "balancer" and 3 application servers. Instance of application run on every server.
The balancer delegates request to 1 of these 3 servers, for example based on traffic.
My question is, how to deal with websockets? Example:
1) User A logs into an applicition 2) Balancer delegates user A to server 1 3) Web socket is created for user A on server 1 4) User B logs into an applicition 5) Balancer delegates user B to server 3 6) Web socket is created for user B on server 3 7) User A wants to set message to user B 8) Instance of application on server 1 looks for web sockes for user B
Web sockets for user B exists on server 3, not on server 1.
How to deal with situation like this? Should it be treated on application level ( e.g some sync of app instances throught database/messages) or some configuration on "balancer" ?
Thanks for help.