知识卡片

普通读书笔记卡 · 3437.b.4

服务端错误码按故障位置选

理解等级:中级

服务端处理失败应按故障位置选状态码:应用内部异常可用 500;暂时过载或维护而不能接收请求可用 503;网关等中间层等待上游超时可用 504。区分它们能让客户端判断是服务异常、暂不可用,还是上游响应超时。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Microservice APIs》第 4 章《Principles of REST API design》(源文件:_epub-src/OEBPS/Text/04.htm) - 结论依据:原文分别以应用崩溃、服务过载或维护、代理等待上游超时解释 500、503、504 的处理场景。 - 原始内容:In those situations, we respond with a 500 (Internal Server Error) status code ... when the server is unable to take on new connections, we must respond with a 503 (Service Unavailable) status code ... When the server takes too long to respond to the request, we respond with a 504 (Gateway Timeout) status code