易混淆错误码解析

易混淆错误码解析

常见错误码

We all come across website errors at some point, and every website out there has inevitably experienced their share of 404 and 500 status codes, which are shown when a URL is not found either due to their typo or a broken link (404), and when there is a general server error (500).

网站日常维护中,我们都不可避免的遇到过404和500状态码,
其中,404表示找不对对应的URL网页,500是通用服务器错误。

There are many other less well known status codes in the 400 and 500 range: Those HTTP status codes beginning with 4 are errors on the client side, and codes beginning with 5 are errors on the side of the website server.

在4xx-5xx的范围内,还有很多不常为人知道的状态:这些状态中4开头的表示客户端的错误,5开头的表示服务端的错误。

在这些错误码中,我们经常感到困惑的是499 vs 502 vs 504

499 vs 502 vs 504对比分析

错误码 错误内容 报错端 出现场景
499 服务端超时 客户端代理 服务端未在客户端设定的时间内响应结果,客户端主动断开连接。比如:服务器接口内SQL超时,导致接口超时。
502 网关错误 服务端代理 网站服务器返回不能识别的响应结果。比如:php-fpm未启动,或者php-fpm 挂了,或者PHP-fpm的max_childen设置太小,高并发场景下,连接耗尽。即问题出现时需要排查PHP-fpm的情况
504 网关超时 服务端代理 服务器未在反向代理设置的时间内响应。比如:nginx的fastcgi_read_timeout参数设置过小,后端服务响应慢时。即PHP-fpm没有在nginx规定的时间内返回数据。

参考资料

  1. The difference between a 502, 503 and 504 error