Comparison
Connection drainingvsSession affinity
Connection draining
the instance is taken out of rotation but its open connections are allowed to finish, instead of being cut mid-response.
Stopping new connections to a backend being removed while letting existing ones complete, up to a timeout. It is the load balancer's half of a clean shutdown, and it must overlap with the workload's own grace period or requests are dropped in the gap. Long-lived connections — websockets, streaming, gRPC — are where a drain timeout tuned for short requests visibly fails.
Full entry →Session affinity
you pin each user to the same instance so the state cached in that process is still there on their next request.
Routing a client's requests consistently to one backend. It makes in-process state usable, which is sometimes the only practical option for WebSockets or large session data. It also breaks even load distribution, prevents clean draining on deploy, and turns one instance's death into a visible failure for a subset of users.
Full entry →