In AWS, when you enable Connection Draining on a load balancer, any back-end instances that you deregister will complete requests that are in progress before deregistration. Likewise, if a back-end instance fails health checks, the load balancer will not send any new requests to the unhealthy instance but will allow existing requests to complete.
This means that you can perform maintenance such as deploying software upgrades or replacing back-end instances without impacting your customers’ experience.
Connection Draining is also integrated with Auto Scaling, making it even easier to manage the capacity behind your load balancer. When Connection Draining is enabled, Auto Scaling will wait for outstanding requests to complete before terminating instances.
When you enable connection draining, you can specify a maximum time for the load balancer to keep connections alive before reporting the instance as de-registered. The maximum timeout value can be set between 1 and 3,600 seconds (the default is 300 seconds). When the maximum time limit is reached, the load balancer forcibly closes connections to the de-registering instance.
A use case scenario: When you have auto scaling and ELB working together and you have a scale down rule. Let’s say you hit the alarm for scale down rule and one of your instance needs to be terminated. In this case, connection draining will wait for the time specified (example 300 seconds) to drain all the ongoing connections. No new connections will be initiated to that back-end instance. This means that the customer/ client that’s taking to the backend server is more likely to finish it’s job rather than having a lost connection/ bad response.
What is Deregistering? Deregistering an EC2 instance removes it from your load balancer. The load balancer stops routing requests to an instance as soon as it is deregistered
Connection Draining is one of the topics required to be learned for the AWS solutions architect/ sysops admin exam.
A sample question will be as follows: