Interview Prep/AWS/Route 53, CloudFront, API Gateway and Messaging

API Gateway returns `504` with `{"message": "Endpoint request timed out"}` on long requests.

IntermediateTroubleshootingRoute 53, CloudFront, API Gateway and Messaging
Answer

Likely causes → The integration took longer than the integration timeout. The default is 29 seconds; for Regional and private REST APIs it can be raised with a quota increase, which may lower throttle limits.

Diagnose →

aws apigateway get-integration --rest-api-id abc123 --resource-id res1 --http-method POST --query timeoutInMillis
aws cloudwatch get-metric-statistics --namespace AWS/ApiGateway --metric-name IntegrationLatency \
  --dimensions Name=ApiName,Value=orders --extended-statistics p99 --period 60 \
  --start-time $(date -u -d '-1 hour' +%FT%TZ) --end-time $(date -u +%FT%TZ)

Fix →

  1. Make the long work asynchronous: the API puts a job on SQS or Step Functions and returns 202 with a job ID, and the client polls or gets a callback
  2. Optimize the backend call

Prevent → Design APIs so every synchronous call finishes in a few seconds.

aws All AWS questions Roadmap: AWS core services

More on Route 53, CloudFront, API Gateway and Messaging