Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Q050】http 状态码 502 和 504 有什么区别 #51

Open
shfshanyue opened this issue Nov 22, 2019 · 2 comments
Open

【Q050】http 状态码 502 和 504 有什么区别 #51

shfshanyue opened this issue Nov 22, 2019 · 2 comments
Labels

Comments

@shfshanyue
Copy link
Owner

No description provided.

@sjfkai
Copy link

sjfkai commented Nov 22, 2019

  • 502 Bad Gateway
    The server was acting as a gateway or proxy and received an invalid response from the upstream server.
    收到了上游响应但无法解析

  • 504 Gateway Timeout
    The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
    上游响应超时

@shfshanyue
Copy link
Owner Author

这两种异常状态码都与网关 Gateway 有关,首先明确两个概念

  • Proxy (Gateway),反向代理层或者网关层。在公司级应用中一般使用 Nginx 扮演这个角色
  • Application (upstream serrver),应用层服务,作为 Proxy 层的上游服务。在公司中一般为各种语言编写的服务器应用,如 Go/Java/Python/PHP/Node 等

此时关于 502 与 504 的区别就很显而易见

  • 502 Bad Gateway。一般表现为你自己写的应用层服务(Java/Go/PHP)挂了,网关层无法接收到响应
  • 504 Gateway Timeout。一般表现为应用层服务 (upstream) 超时,如查库操作耗时十分钟,超过了 Nginx 配置的超时时间

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants