websocket communication between clients in distributed system
<p>I'm trying to build instant messaging app. Clients will not only send messages but also often send audios. And I've decided to use websocket connection to communicate with clients. It is fast and allows to send binary data. <br><br>
 The main idea is to receive from <strong>client1</strong> message and notify about it <strong>client2</strong>. But here's the thing. My app will be running on GAE. And what if <strong>client1</strong>'s socket is opened on <strong><em>server1</em></strong> and <strong>client2</strong>'s is opened on <strong><em>server2</em></strong>. This servers don't know about each others clients.<br><br>
I have one idea how to solve it, but I am sure it is shitty way. I am going to use some sort of communication between servers(for example JMS or open another websocket connection between servers, doesn't matter right now).<br>
 But it surely will lead to a disaster. I can't even imagine how often those servers will speak to each other. For each message <strong><em>server1</em></strong> should notify <strong><em>server2</em></strong>, <strong><em>server2</em></strong> should notify <strong>client2</strong>. But things become even worse when <strong><em>serverN</em></strong> comes into play.<br><br>
Another way I see this to work is Firebase. But it restricts message size to 4KB. So I can't send audios via it. As a solution I can notify client about new audio and he goes to my server for it.<br><br>
Hope I clearly explained the problem. Does anyone know how to solve it? Or maybe there are another ways to build such apps? </p>