tool::http-status-detail
504 Gateway Timeout
The gateway did not receive a timely response from an upstream server.
상태 코드
504
이름
Gateway Timeout
카테고리
5xx상세 설명
HTTP 504 Gateway Timeout은 게이트웨이나 프록시 서버가 업스트림 서버로부터 제때 응답을 받지 못했음을 나타냅니다. 502(잘못된 응답)와 달리 504는 응답 자체가 오지 않은 타임아웃 상황입니다. 업스트림 서버가 느린 데이터베이스 쿼리나 외부 API 호출로 인해 응답이 지연될 때 자주 발생합니다.
주요 원인
- ▸업스트림 서버가 느린 데이터베이스 쿼리로 응답이 지연되는 경우
- ▸프록시의 타임아웃 시간보다 업스트림 처리 시간이 더 긴 경우
- ▸업스트림 서버가 과부하로 인해 응답이 느려진 경우
- ▸외부 API 호출이 지연되어 전체 요청이 블로킹된 경우
- ▸네트워크 혼잡으로 인해 패킷 전달이 지연되는 경우
해결 방법
- 1.Nginx의 proxy_read_timeout, proxy_connect_timeout 값을 늘리세요
- 2.느린 데이터베이스 쿼리를 최적화하세요 (실행 계획 분석 등)
- 3.업스트림 서버의 부하를 확인하고 스케일아웃을 고려하세요
- 4.외부 API 호출에 타임아웃과 서킷 브레이커 패턴을 적용하세요
- 5.장시간 작업은 비동기 처리(큐, 워커)로 분리하세요
관련 HTTP 헤더
Retry-AfterServer응답 예시
HTTP/1.1 504 Gateway Timeout Server: nginx/1.24.0 Content-Type: text/html <html><body><h1>504 Gateway Timeout</h1><p>The upstream server did not respond in time.</p></body></html>
관련 상태 코드
500Internal Server ErrorThe server encountered an unexpected condition.→501Not ImplementedThe server does not support the requested functionality.→502Bad GatewayThe gateway received an invalid response from an upstream server.→503Service UnavailableThe server is temporarily unable to handle the request.→505HTTP Version Not SupportedThe HTTP version used in the request is not supported.→
ad · 300×250
// related tools