amazon-web-servicestimeoutamazon-cloudfronthttp-status-code-504

Cloudfront timeout connection vs response timeout


I have a legacy app running that has an endpoint taking about 65 seconds to return a response. This is configured as an origin behind cloudfront, and the browser shows a 504 gateway timeout from cloudfront after 180 seconds.

The cloudfront distrubtion has default settings i.e. 10s connection timeout, 30s response timeout, 3 connection attempts.

The solution to my problem is just to bypass cloudfront for this call (its internal use so can hit the app directly), but I'm looking for clarification on these timeouts anyway as they aren't working as I'd expected. Shouldn't the timeout error appear after 30 seconds?

Logs from the app show that the endpoint is actually being hit 3 times, so it looks like cloudfront is replaying the request every 30 seconds for 3 attempts before it bails. But isn't the "connection attempts" value of 3 just for connects not response timeouts?


Solution

  • The response timeout is the time CloudFront waits after sending a request to the origin to get the first byte of a response. If it doesn’t get anything back in 30 seconds, it retries. and you already has 3 connection attempts that's why you're getting the error 3 times.

    Connection Timeout (10 seconds): This is the time CloudFront waits to establish a connection to your origin server. If it doesn’t connect in 10 seconds, it retries.

    Response Timeout (30 seconds): This is the time CloudFront waits after sending a request to the origin to get the first byte of a response. If it doesn’t get anything back in 30 seconds, it retries.

    Connection Attempts (3): CloudFront tries a maximum of 3 times to either connect to the origin or get a response (this applies to both connection and response timeouts). If all attempts fail, it gives up and returns a 504 error.

    The 3 connection attempts in CloudFront’s settings apply to both Response Timeout and Connection Timeout