First request to AWS ELB is slow every time


Looking to understand AWS Classic Load Balancing here. I have an elastic beanstalk web application running behind a classic ELB where I am currently the only traffic (under development). When I send a request, the first time it always takes exactly 1.26 minutes. If I send another request shortly after it responds instantly. However, if I wait for what seems like a couple minutes, it will revert back to the 1.26 minute response time.

I have tried both enabling and disabling cross-zone load balancing and sticky sessions, with no change to the response times.

I have also tried running the request from different processes, and 1 request succeeding on 1 process doesn’t make the other process respond instantly (they both have a slow first request).

I am looking to understand why this is happening and how do I prevent this from happening for all users for their first request?

I have 2 availability zones and there is 1 ec2 instance in each zone running the application. I also have them in private subnets and the load balancer in 2 public subnets corresponding to each availability zone.

I am also using nginx for elastic beanstalk, here is my config:

I believe we can rule out the following:

  1. I have verified that DNS is resolved instantly (tried pinging and then requesting (no effect), and using dig responds instantly)
  2. The application is not receiving the request for 1.27 minutes (so it’s not a CPU/database latency issue).

It seems to be something between when the load balancer gets the request and when the ec2 instance gets the request, but I’m not sure how to debug that. I am seeing a lot of TCP Retransmissions in wireshark before the response returns.


It might be because of the incorrect VPC configurations!

Recently, I bumped into the same issue and for me, route table was the culprit. One of my public subnets that were attached to the ALB was not routing the traffic to the internet gateway.

So, just make sure the route table attached to your public subnets attached to your loadbalancer has a route to your internet gateway for destination range

This post made me check my route tables and other VPC settings.

Leave a Reply