For anyone wanting to do this sort of thing, check out Pushpin [1]. It's a proxy server that can manage raw WebSocket connections on behalf of any HTTP backend. There are middleware libraries (such as [2]) to make it easy to write handler code.
Disclosure: lead dev. Came up with the idea after developing a custom connection manager thing at a previous company.
[1] https://pushpin.org [2] https://github.com/fanout/js-serve-grip/blob/master/examples...
“This part of our back-end, responsible for most of the real-time interactions happening in various clients, is implemented in Java, and accessed via a WebSocket API described here: Real Time Messaging API. A great deal of the user experience that makes Slack feel like Slack is the result of careful work on the message server. Many of the distributed systems challenges we face on the back-end are in coordinating this service with the rest of the (LAMP-ier) back-end.”
Plus it requires the backend to support that custom multiplexing layer.
This way you could restart service without killing ws connection, move all overhead of handling millions of connections to the lb.