Glossary · Networking

Connection Draining

Connection draining lets a load balancer stop sending new requests to an instance while allowing its existing connections to finish before removal.

Updated October 14, 2026

Connection draining, also called deregistration delay, is a load balancer feature that gracefully removes a backend. The instance is marked as draining, receives no new connections, and keeps serving the ones already open until they finish or a timeout expires.

Why it matters

Without draining, taking a server out of rotation during a deploy or scale-in can sever active downloads, API calls and WebSocket sessions, which users see as random errors. Draining turns removal into a quiet event. The right timeout is a trade-off: too short cuts off legitimate work, too long slows deployments.

Example

HAProxy can put a server into drain mode through its runtime API:

echo "set server app/web2 state drain" | socat stdio /var/run/haproxy.sock

Existing sessions continue, and new ones go to other servers. After the connection count reaches zero, stop the process. Cloud load balancers expose the same idea as a setting, often with a default of a few minutes; check your provider's documentation for the exact name and default.

Common mistakes

  • Setting the drain timeout shorter than your longest request or WebSocket session.
  • Stopping the application at the same instant as deregistering it.
  • Forgetting that sticky sessions can keep clients attached to a draining node.

Get notified when this term updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.