peerjs-server icon indicating copy to clipboard operation
peerjs-server copied to clipboard

unsuitable for large / distributed application?

Open Awendel opened this issue 3 years ago • 2 comments

As far as I can tell, all state around connections is handled in memory and exchanged with Clients through the websocket protocol.

Now suppose I have a rather large applications with a load balancer and let's say 20 Servers behind it that the LB routes to.

Wouldn't there be the problem that when opening a Websocket, clients wouldn't "find" each other if they're not connected to the exact machine / websocket connection and hence connections wouldn't be possible?

The only way around it seems to add a centralised database, such as Redis, Memcached or Mongo to share state between Servers?

If that is the case, it would maybe be a good idea to add a disclaimer in the README that it's not suited for distributed / load balanced applications.

Awendel avatar Aug 17 '21 12:08 Awendel

Shouldn't be hard to add DB support. Redis is probably the simplest and most fitting.

Though, it's worth to mention that having an open Websocket use very little bandwidth and server resources so you would need to have a significant amount of connections to need a load balancer.

Givemeurcookies avatar Aug 20 '21 14:08 Givemeurcookies

It would be interesting to hear if someone has load tested a peerjs-server, then we might be aware of it's limitations.

rushglen avatar Nov 02 '21 03:11 rushglen