Your company has set up a Classic Load Balancer with EC2 Instances behind them.
These EC2 Instances are spun up via an Autoscaling group.
In your company, there is normally a spike in traffic in the beginning and end of the day.
The ELB and Autoscaling Groups have been created with the default settings.
Sometimes, it has been noticed that there are timeouts or partially rendered pages when the instances terminate.
How can this be resolved?
Click on the arrows to vote for the correct answer
A. B. C. D.Answer - B.
The most likely reason is that when the instances are terminated by Autoscaling, the requests are partially fulfilled and not completed.
In such a case, you can increase the connection draining on the ELB.Option A is invalid because it is when the Instances are terminating that is the issue.
Option C is invalid because you can disable connection draining if you want your load balancer to immediately close connections to the instances that are de-registering or have become unhealthy.
When connection draining is disabled, any in-flight requests made to de-registering or unhealthy instances are not completed.
Option D is invalid because you don't need multiple Autoscaling groups for this.
For more information on Connection Draining, please refer to the below URL.
https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-conn-drain.htmlWhen traffic spikes occur, the Autoscaling Group will add more EC2 instances to handle the load. If the ELB does not balance the traffic evenly across the available EC2 instances, it can cause timeouts or partially rendered pages when the instances terminate. To resolve this issue, we can take the following steps:
Change the Connection Draining timeout in the ELB: By default, the connection draining timeout is set to 300 seconds. This means that when an instance is terminated, the ELB waits for up to 5 minutes before closing the connection to that instance. If the maximum number of instances in the Autoscaling Group is reached, new instances may not have enough time to warm up before the old instances are terminated, resulting in partially rendered pages or timeouts. By increasing the Connection Draining timeout, the ELB will wait longer before closing the connection to terminated instances, giving new instances more time to warm up.
Change the maximum number of instances setting in the Autoscaling Group: By default, the maximum number of instances in an Autoscaling Group is set to 20. If the maximum number of instances is reached and new instances are needed to handle the traffic, the Autoscaling Group will terminate some of the existing instances to make room for the new ones. This can cause partially rendered pages or timeouts if the ELB does not balance the traffic evenly across the remaining instances. By increasing the maximum number of instances in the Autoscaling Group, more instances can be added to handle the traffic without terminating existing instances.
Add another Autoscaling group to the ELB: Adding another Autoscaling Group to the ELB can help distribute the traffic across multiple groups, preventing any one group from becoming overloaded. This can help reduce the likelihood of partially rendered pages or timeouts when instances are terminated.
Disable Connection Draining: Disabling Connection Draining can cause the ELB to immediately terminate connections to instances that are being terminated. This can result in partially rendered pages or timeouts if new instances are not yet ready to handle the traffic. Therefore, it is not recommended to disable Connection Draining.
In conclusion, the best solution to resolve the issue of timeouts or partially rendered pages when instances terminate is to increase the Connection Draining timeout in the ELB and/or increase the maximum number of instances in the Autoscaling Group. Adding another Autoscaling Group to the ELB can also help distribute the traffic across multiple groups.