DEV Community

Discussion on: Horizontal scaling WebSockets on Kubernetes and Node.js

Collapse
 
rmgrimm profile image
Robert Grimm

Nice article!

Quick question though: how would you handle open websockets on pods that are being scaled down? It seems that without any additional handling, those active connections will be cut prematurely, right?

Collapse
 
tareksamni profile image
Tarek N. Elsamni

From practice, they will get disconnected and retry to connect again. They eventually get connected/reallocated to a new pod. It happens almost instantly!

Collapse
 
rmgrimm profile image
Robert Grimm

Sure, if the client was build with reconnect logic, then the client will reconnect.

So it seems like something to keep in mind when adding HPA to websockets: make sure the websocket clients can gracefully handle connection drops at any time 👍

Thread Thread
 
tareksamni profile image
Tarek N. Elsamni

ActionCable, Socket.io and WebSocket library do reconnect automatically when connection is dropped. But as you mentioned you should always think about such scenarios in planning a reliable software