AWS: Increase Connection Timeout

Environment: Elastic Beanstalk - Java with Tomcat

Recently, we faced a situation where java-tomcat server was taking more than 60 seconds to process the request. And we were getting Bad Gateway 5xx Errors. For this particular use case, we could not use asynchronous communication protocol such as Queues; And business users were more than happy to wait for requests to complete even if it takes more than a minute.

For every request, Classic Load Balancer maintains 2 connections. One connection is from client to load balancer, and another connection from load balancer to ec2-instance. By default, idle timeout of classic load balancer is set to 60 seconds which means it can close connection if data is not sent within 60 seconds. In order to handle requests which takes more than 60 seconds to process, we can edit the idle timeout setting and increase it to any value upto 4000 seconds. However, If we want to handle requests which takes more than 60 seconds to process, then Load Balancer Idle time out is not the only setting that we need to modify. We also need to modify time out setting for Apache as Elastic Beanstalk uses Apache as Proxy Server.
  1. Log into ec2 instance and find httpd.conf file at following path:
    nano /etc/httpd/conf/httpd.conf 
    Change Timeout setting to x seconds where x > 60. If keep Alive is on, then make sure KeepAliveTimeOut is greater than Timeout. Restart Apache server:
    sudo service httpd restart
  2. Log into ec2 management console and change idle timeout setting of classic load balancer to x seconds. Now test web server with requests which were failing because of timeout. These requests should be fine now.
  3. If you are happy with timeout settings, then download the httpd conf file which was modified earlier. And make this conf file part of war file in .ebextensions folder. This way, with every new deployment, elastic beanstalk will replace default httpd conf with modified file, found in war, when processing pre-hook commands. Project Structure can look similar to this: (where .ebextensions is at root of project)
Stack Overflow
AWS Docs
AWS Forum


  1. The Pomsky is a designer breed of dog that is a hybrid of the Pomeranian and the Siberian Husky. Adorable Pomsky puppies have attracted a lot of attention recently and made them one of the most popular breeds of 2017.
    Best Online Pet Adoption : Cavapoo Puppies For Sale : Australian Shepherd Puppies Below $200 : Available Maltipoo Puppies Online : Where To Buy Golden Retriever Puppies OnlineBest Online Adoption|Healthy Puppies for Sale|Cavapoo puppies for sale

  2. I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.Buy parrots in Texas

  3. Thanks for sharing What an interesting site you have i really take a good look buy cocaine online and you can also take a good look at our blog too for more information buy crack cocaine online we also recommend you to take a good look at this site too they have good content buy mdma crystals online more of the site still want you to take a closer look too as they have really good content buy crystal meth online thanks for using your time to check on the link .order cocaine online

    k2incenseonlineheadshop Buy liquid incense cheap Buy liquid incense cheap For Sale At The Best Incense Online Shop


    Buy liquid incense cheap | cheap herbal incense | buy k2 E liquid | k2 spray
    Buy liquid incense cheap . cheap herbal incense . buy k2 E liquid . buy k2 paper spray online . buy herbal incense online . buy k2 spice online

    Buy K2 Infused paper spray online, order K2 Spray online +1 (925) 526-5453


    Buy cheap liquid herbal incense at your best online shop



    Buy Driver’s License online, US driver license, drivers license renewal ca WhatsApp +1 (925) 526-5453

    Here at Buy Documentation, you can buy fake documents at a fraction of a cost. We keep our prices low to meet the needs of all our customers. We provide Best Quality Novelty Real and Fake IDs and Passport, Marriage Certificates and Drivers license online


Post a comment

Popular posts from this blog

Practice Questions - AWS Solutions Architect - Associate Certification

AWS Parameter Store