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.
Stack Overflow
AWS Docs
AWS Forum
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.
-
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
- 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.
-
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)
.ebextensions
--httpd
----conf
------httpd.conf
--files.config
Stack Overflow
AWS Docs
AWS Forum
Afghan Kush
ReplyDeleteAK-47
buy weed online
AK-47 dank vape
painkiller
cocaine
Amnesia Haze
buy weed online
Afghan Kush
legit online dispensary shipping worldwide
buy weed online
painkiller
buy weed online
cocaine
Amnesia Haze
magnificentincense.com
ReplyDeleteMedical marijuana is a plant-based medicine from the Cannabis sativa or Cannabis indica species with three major active compounds: THC, CBD, and CBN.
ReplyDeleteLegit weed Worldwide Shipping|legit online dispensary shipping worldwide|colorado dispensary shipping worldwide|online dispensary shipping worldwide paypal|legit online dispensary shipping worldwide reviews|Buy Weed Online|Online Dispensaries that Ship worldwide
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.
ReplyDeleteBest 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
Cavapoo puppies
ReplyDeleteBeagle puppies for Sale
Cavapoo Puppies For Sale Under $500
Cockapoo Puppies
Maltipoo Puppies
Goldendoodle
Rottweiler
Parrots for sale
Puppies For Sale
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
ReplyDelete