Thursday, May 22, 2025

Connection Draining : Concept, Features, Benefits, Limitations, and Use Cases.

 

Connection Draining – Concept, Features, Benefits, Limitations, and Use Cases

 Concept

Connection Draining (also known as deregistration delay in AWS ELB) is the process of gracefully removing or shutting down backend servers (e.g., in a load balancer or auto-scaling group) without interrupting active connections. It allows existing requests to complete while preventing new ones from being sent to the target instance or service.

 Key Features

  • Graceful Decommissioning: Allows in-flight requests to complete before terminating the instance or deregistering it from the load balancer.
  • Timeout Control: A maximum timeout period can be set after which existing connections are forcefully closed.
  • State Awareness: Integrates with health checks and scaling policies to avoid routing traffic to unhealthy or decommissioned instances.

 Benefits

Benefit

Description

 Improved User Experience

Prevents dropped or abruptly terminated user sessions.

 Safe Deployments

Enables rolling deployments and updates with zero downtime.

 Smooth Scaling

Facilitates seamless removal of instances during scale-in events.

 Operational Stability

Helps maintain service reliability and uptime during maintenance or upgrades.

Limitations

Limitation

Description

Added Latency

Waiting for draining to complete can delay instance shutdown.

 Client Awareness

Clients may still experience issues if they retry requests during the draining phase without proper retry logic.

 Not Foolproof

Long-lived connections may delay or prevent instance termination if not handled correctly.

 Configuration Complexity

Requires proper integration and tuning (e.g., drain timeout, app support for graceful termination).

 Use Cases

Use Case

Description

 Rolling Deployments

Replace app versions one by one without dropping traffic.

 Auto Scaling (Down)

Remove instances without interrupting user sessions.

 Maintenance Windows

Perform updates or reboots without affecting users.

 Fault Isolation

Remove unhealthy instances while keeping active requests intact.

twtech - Example for: AWS Network Load Balancer

In AWS:

  • Connection Draining for ALB is called "Deregistration Delay".
  • Default is 300 seconds.
  • During this time, no new connections are sent to the instance, but existing ones are allowed to complete.
  • Connection Draining is a direct concept  associated with CLB (classic load balancer)

Project: Hands-on

How twtech configures the frequency of Deregistration delay  or routing to the target group:

Edit target group attributes:twtech-nlb-tg

From: Deregistration delay (draining interval). As of May 2025,this settings vary from 0 - 3600 seconds

The time to wait for in-flight requests to complete while deregistering a target. During this time, the state of the target is draining.

To:

Save changes:

No comments:

Post a Comment

Kubernetes Clusters | Upstream Vs Downstream.

  The terms "upstream" and "downstream" in the context of Kubernetes clusters often refer to the direction of code fl...