Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ugh, how do you shard websocket connections when you have more connection than 1 server can handle ?


If you use Elixir/Phoenix, you can have many servers running same code, connected with each other as Erlang nodes. When client wants to broadcast something in whole network, it is broadcasted locally but is also sent do all servers and servers broadcasts it to their local clients. It's very easy to write.


It's not ideal for sure but you can use DNS to divvy it up by adding several IPs to your domain name.


You can also do it out of band and have an API call that returns the server you're supposed to be connected to.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: