In this tutorial, we will know to Chat Applications System Design. A Modern Chat Application System Database Architecture That Almost Every Chat App Uses
So let's say A sends a message to B and we will be using gateways to connect the users for handling the security there in itself. So once you get connected to the gateway and A sends a message to B, but here we have to store which user is connected to which gateway to make the service faster.
Once the gateways know that the user B is connected to Gateway 2 it will connect to that gateway and sends the message ahead, but for that, we need to send that information somewhere and for that, we will be using sessions microservice because storing that data in the gateways itself will be an expensive matter here because gateways are already occupied with handling user request and that requires a lot of memory so that's why we need sessions microservice for that.