Question

Does websocket handshake works out of the box with horizontal scaling?

I am in the process of starting a new project with a Node.js app hosted on App Platform for which I will need horizontal scaling.

This app will, among other things, use websockets to communicate with the frontend part.

I saw this post in which the answer state that a correlation strategy must be setup for the websocket communication to work in a multi-instances environment.

Is it still the case? And is there anything particular to do regarding the handshake phase of the connection?

Thanks,


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

👋 @tbordiga

Yes, apps that use websockets will need some sort of correlation strategy if the app is using horizontal scaling.

With websockets once the connection is made you will continue to be directed to the same instance of the app until that connection is broken. So handshakes between instances for established connection isn’t necessary, however, each instance will (likely) need to maintain a list of clients connected to it and use something (eg. pub/sub) to dispatch messages that all of the instances can read and then direct to the appropriate client.s