4 ms·
I am curious about backend part - do ws is still ws on services? Why? For example, why to have thousands of connections instead of a single one (or a bunch) tha
by ex3ndr 6y ago
I am curious about backend part - do ws is still ws on services? Why? For example, why to have thousands of connections instead of a single one (or a bunch) that simply forwards websocket packets with some "connection id" with them.
This way you could restart service without killing ws connection, move all overhead of handling millions of connections to the lb.
- Matthias247 6y agoYou could do that. But it would introduce a lot of head of line blocking on that connection. In return you Save a TLS handshake which might not be too important for long lived connections. Plus it requires the backend to support that custom multiplexing layer.
- muxator 6y agoHow so? Why there should be a head of line blocking? This would be a simple multiplexing of the payloads.
- Matthias247 6y agoIf there on the other connection a lot of messages are exchanged (and a websocket frame could be gigabytes long according to the spec) the other stream would be blocked behind that.Of course that can be mitigated by using a non websocket framing, but that in the end reinvents yet another transport layer.
- bpicolo 6y agoIf I remember right, Slack's main application was PHP, now Hack, based, so I wouldn't be surprised to hear that app doesn't hold onto websocket connections itself - long-lived connections aren't historically PHP's wheelhouse
- jkarneges 6y ago> why to have thousands of connections instead of a single one (or a bunch) that simply forwards websocket packets with some "connection id" 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 https://pushpin.org [2] https://github.com/fanout/js-serve-grip/blob/master/examples/express-ws/server.js https://github.com/fanout/js-serve-grip/blob/master/examples...
- winrid 6y agoIf you're looking to do this, I recommend the Nchan module for Nginx.
- ec109685 6y agoSlack has a Java server managing real-time messaging: https://www.quora.com/What-is-the-tech-stack-behind-Slack https://www.quora.com/What-is-the-tech-stack-behind-Slack “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.”