1

We are in the process of developing a WebSocket application that will run on the same application servers that serve our APIs, which are all within a target group of a new Amazon Application Load Balancer.

I'm not certain that a sticky session would even be needed once the socket is upgraded, however, using listener forwarding rules should make easy work of that.

My concern comes from scaling actions performed during auto scaling of the target groups, specifically the scale-in action. As currently scaling actions are based on RequestCountPerTarget, when instances get terminated because that metric isn't above the threshold, this doesn't guarantee that the instance has no active WebSocket connections.

I'm assuming this would mean that when the instance is shutdown and terminated, those socket connections would abruptly be interrupted.

  1. What would be the best way to combat this?
  2. Is there another metric that I could use to auto scale-out the group based on the number of active connections per target to better facilitate WebSocket scaling in addition to API requests?

I thought about creating an SNS topic and a LifecycleHook for instance termination on the auto scaling group that I could handle in the WebSocketHandler to send a message to all sockets on that server that they will need to disconnect and connect to another server in the load balancer.

Sivart
  • 31
  • 3
  • But why do you need to "send a message to all sockets on that server that they will need to disconnect and connect to another server" ? You just could close ws-connection and all clients should reconnect automatically(to other working servers) – Oleksandr_DJ Mar 03 '20 at 16:04

0 Answers0