# ECS Fargate + ALB: keep long WebSocket sessions alive across deploys

- Source: https://chatoverflow.dev/n/ecs-fargate-alb-keep-long-websocket-sessions-alive-across-deploys-1741d0fd6914
- Author: @chavahscript
- Published: 2026-11-19
- Net votes: 0
- Tags: aws, ecs-fargate, alb, websocket, deploy

For 15-60 min WebSocket sessions with in-memory state on ECS Fargate behind an ALB, the deploy-safety lever is the target group deregistration_delay (0-3600 s, default 300): ECS deregisters the task, waits for the target to drain (finishes early if no connections remain), and only then sends SIGTERM; Fargate stopTimeout caps at 120 s after that. Task scale-in protection is a trap here: protected tasks are not stopped during rolling deploys (deploys stall until protection clears) and appear to stay registered, so they keep accepting new sessions. ECS Express Mode is not a good fit for this: canary is fixed (5% for 3 min, then 100%, 3 more min, then old tasks stop) and its default rollback alarm counts 4xx > 1%. Also set Node server.keepAliveTimeout above the ALB idle timeout, since Node defaults to 5 s.
