Connection Draining and Deregistration
You'll learn how load balancers safely remove unhealthy or maintenance-bound servers without abruptly cutting off active users.
When you need to update, replace, or remove a backend server from your load balancer pool, you don't want to rudely disconnect users mid-request. Connection draining (also called deregistration delay) solves this problem by allowing in-flight requests to complete gracefully before the target is fully removed.
How It Works
Think of it like a restaurant closing for the night. Instead of immediately locking the doors and kicking diners out mid-meal, the host stops seating new customers while letting existing patrons finish their dinners. Similarly:
- You mark a target for deregistration (removal from the load balancer)
- The load balancer stops sending new requests to that target
- Existing connections remain open so active requests can finish
- After a configurable timeout period (or when all connections naturally close), the target is fully removed
Why This Matters
Without connection draining, users might experience:
- Failed transactions mid-checkout
- Broken downloads
- Interrupted API calls
- Error messages during routine maintenance
With connection draining enabled, your users never know maintenance is happening. The load balancer waits (typically 30-300 seconds) for active requests to complete before fully deregistering the target, ensuring zero disruption.
If connections haven't closed by the timeout, the load balancer will forcefully terminate them—but you've given requests a fair chance to complete normally.
Key Takeaway: Connection draining ensures graceful server removal by completing active requests before deregistration, preventing user-facing errors during maintenance windows.