Ask HN: Approaches to load balancing web sockets?

1 points by jcun4128 ↗ HN
Might be simple, just trying to think of sane ways to do it. These are plain web sockets in Web JS to Node not using something like socket.io. It's user A to server to user B and vice versa.

There would be some kind of db involved in the event of it going down/can reconnect people by some ids.

My concern is do you keep say multiple domain options on the app (by env variables) or do you have a single url you hit (no?) and that branches off to different instances.

Scale is small now as in 10/100s of users, performance is not like a video game but still real time/more than text chat. The data rate is still low, mostly transferring meta data.

6 comments

[ 3.1 ms ] story [ 21.2 ms ] thread
If you select the first option (multiple domains), the load balancing would be done by the client ( hit one domain, on failure hit next.)
It looks like the other thing I'm missing is the shared database. Which idk if Postgres counts, my stuff is not that high performance but wondering if I need something else like Redis.
Postgres supports clustering and replication.
Okay I will look into that. I already use Postgres for the rest of the app idk if I need to introduce another thing just for websocket connection persistence through multiple instances.