AWS Certified Developer – Associate (DVA-C02)Troubleshooting and MonitoringEasy

A developer has deployed a new web application on AWS using Amazon EC2 instances behind an Application Load Balancer (ALB). Users are reporting intermittent 504 Gateway Timeout errors. The EC2 instances are running Amazon Linux 2, and the application logs show no errors at the time of the 504s. CloudWatch metrics for the EC2 instances show CPU utilization below 30% and sufficient free memory. Which of the following is the MOST likely cause of these 504 errors?

  1. AThe EC2 instances are not correctly registered with the Application Load Balancer's target group.
  2. BThe application's processing time for certain requests exceeds the target group's configured timeout.
  3. CThe deregistration delay for the target group is too short, causing requests to be sent to instances being terminated.
  4. DThe security group associated with the EC2 instances is blocking inbound traffic from the Application Load Balancer.
Show answer & explanation

Correct answer: B. The application's processing time for certain requests exceeds the target group's configured timeout.

A 504 Gateway Timeout error from an ALB typically indicates that the load balancer did not receive a response from a registered target within the configured timeout period. Since application logs show no errors and instance metrics are healthy, the application itself is likely taking too long to process specific requests.

Why the other options are wrong

  • A. If instances were not registered, the ALB would likely return 503 Service Unavailable or continuously fail, not intermittent 504s, and health checks would fail.
  • C. A short deregistration delay can cause 503 errors during scaling events, but less commonly intermittent 504s when instances are healthy and not actively terminating.
  • D. If security groups were blocking traffic, the ALB would not be able to reach the instances at all, leading to 503 errors and failed health checks, not intermittent 504s.

ALB 504 Gateway Timeout

An HTTP 504 error returned by an Application Load Balancer (ALB) indicates that the load balancer did not receive a response from a registered target (e.g., EC2 instance) within the configured idle timeout period.

  • Typically means the backend application is taking too long to process a request.
  • Not usually caused by network connectivity issues or instance unavailability (those are often 503s).
  • Can be resolved by optimizing application performance or increasing the ALB target group idle timeout.

Memory trick: ALB 504: Application's Long Backend processing is the cause, often a Timeout.

More Troubleshooting and Monitoring questions