Service Unavailable vs Gateway Timeout
Choose HTTP 503 when the server is temporarily unavailable (overload, maintenance, rate limiting). Choose HTTP 504 when acting as a gateway and upstream times out.
HTTP 503 and 504 both signal server failures, but they differ in context and attribution. 503 (Service Unavailable) indicates the server itself is temporarily unable to handle requests (overloaded, maintenance, rate limiting). 504 (Gateway Timeout) is used when acting as a gateway/proxy and the upstream server doesn't respond in time. The boundary lies in whether it's a direct server issue (503) or a gateway timing out waiting for upstream (504).
Use HTTP 503 for temporary server unavailability; choose HTTP 504 for gateway timeouts.