I have looked around a bit on websockets, and I have a pretty concrete question: Can websockets actually be scaled over different servers, or are they always limited to one single server?
It seems that this is an issue I've repeatedly bumped into in the docs I have found, but maybe they were incomplete or things evolved. It seems for example as heroku even doesn't support websockets at all(?)
But why are WebSockets hard to scale? The main challenge is that connections to your WebSocket server need to be persistent. And even once you've scaled out your server nodes both vertically and horizontally, you also need to provide a solution for sharing data between the nodes.
Scaling WebSockets isn't as simple as just increasing the number of instances. It needs to be configured with some other tools in order to build a fully scalable architecture. Using a Publish/Subscribe or pub/sub broker is an effective method of horizontally scaling WebSockets.
Some WebSockets security vulnerabilities arise when an attacker makes a cross-domain WebSocket connection from a web site that the attacker controls. This is known as a cross-site WebSocket hijacking attack, and it involves exploiting a cross-site request forgery (CSRF) vulnerability on a WebSocket handshake.
It depends on your application, but in general, there is no reason you can't load balance websocket connections to multiple machines in the same way as any other TCP connection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With