Configure the idle connection timeout for your Classic Load Balancer - Elastic Load Balancing

Configure the idle connection timeout for your Classic Load Balancer

For each request that a client makes through a Classic Load Balancer, the load balancer maintains two connections. The front-end connection is between the client and the load balancer. The back-end connection is between the load balancer and a registered EC2 instance. The load balancer has a configured idle timeout period that applies to its connections. If no data has been sent or received by the time that the idle timeout period elapses, the load balancer closes the connection. To ensure that lengthy operations such as file uploads have time to complete, send at least 1 byte of data before each idle timeout period elapses, and increase the length of the idle timeout period as needed.

If you use HTTP and HTTPS listeners, we recommend that you enable the HTTP keep-alive option for your instances. You can enable keep-alive in the web server settings for your instances. Keep-alive, when enabled, enables the load balancer to reuse back-end connections until the keep-alive timeout expires. To ensure that the load balancer is responsible for closing the connections to your instance, make sure that the value you set for the HTTP keep-alive time is greater than the idle timeout setting configured for your load balancer.

Note that TCP keep-alive probes do not prevent the load balancer from terminating the connection because they do not send data in the payload.

Configure the idle timeout using the console

By default, Elastic Load Balancing sets the idle timeout for your load balancer to 60 seconds. Use the following procedure to set a different value for the idle timeout.

To configure the idle timeout setting for your load balancer using the console
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the navigation pane, under Load Balancing, choose Load Balancers.

  3. Choose the name of the load balancer to open its detail page.

  4. On the Attributes tab, choose Edit.

  5. On the Edit load balancer attributes page, in the Traffic configuration section, type a value for Idle timeout. The range for the idle timeout is from 1 to 4,000 seconds.

  6. Choose Save changes.

Configure the idle timeout using the AWS CLI

Use the following modify-load-balancer-attributes command to set the idle timeout for your load balancer:

aws elb modify-load-balancer-attributes --load-balancer-name my-loadbalancer --load-balancer-attributes "{\"ConnectionSettings\":{\"IdleTimeout\":30}}"

The following is an example response:

{ "LoadBalancerAttributes": { "ConnectionSettings": { "IdleTimeout": 30 } }, "LoadBalancerName": "my-loadbalancer" }