Let’s imagine that we have a simple chat application in which the frontend communicates with the backend via rest and WebSockets used for chatting. We realize that one instance of the application starts not to cope with the load.
It’s not a trivial task to scale microservices that uses WebSockets. With a simple launch of another instance under a default round-robin load balancer, we may get a situation when one user connects to instance-A and the second user connects to instance-B. And now, our backends must somehow understand where to send incoming messages.
The first option that may come to mind is to write an intelligent load balancer that will redirect users from the same chat to the same instance.
Several problems can arise here:
#spring-boot #java #websocket #microservices