Course contentsShow
← Cloud and Infrastructure
Lesson 241 of 2,9895. Load Balancing and Traffic ManagementFree lesson

Connection Draining and Deregistration

Learn how load balancers gracefully remove targets while completing in-flight requests during maintenance.

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:

  1. You mark a target for deregistration (removal from the load balancer)
  2. The load balancer stops sending new requests to that target
  3. Existing connections remain open so active requests can finish
  4. 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.