How is 408 Request Timeout different from 504 Gateway Timeout?
408 means the client took too long to send the request to the server; 504 means the server received the request but an upstream backend took too long to respond.
HTTP 408 Request Timeout means the server closed an idle connection because the client did not finish transmitting the full request headers or body within the timeout window.
http {
keepalive_timeout 65s;
client_header_timeout 30s;
client_body_timeout 60s;
send_timeout 60s;
}
curl -i -sS --max-time 30 -X POST --data-binary @payload.json https://api.example.com/upload
408 means the client took too long to send the request to the server; 504 means the server received the request but an upstream backend took too long to respond.
Set your backend server's `keepAliveTimeout` slightly higher than the load balancer's idle timeout (for example, 65s in Node.js/Nginx when ALB is 60s).
Yes, for idempotent requests (or POST requests protected by an `Idempotency-Key` header) using exponential backoff.