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