知识卡片
无状态请求便于横向扩展
REST 的无状态约束要求每个请求携带处理它所需的信息,服务端不保留该客户端跨请求的会话状态。这样多个服务实例都能响应后续请求,降低请求对特定实例的依赖。这里说的是客户端会话状态,不等于服务不能持久化业务数据。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 4 章《Principles of REST API design》(源文件:_epub-src/OEBPS/Text/04.htm)
- 结论依据:原文要求每次请求自带处理信息、不跨请求保留状态,并指出任何实例都可响应客户端,从而便于横向扩展。
- 原始内容:In REST, every request to the server must contain all the information necessary to process it. In particular, the server must not keep state from one request to the next. ... This allows us to deploy multiple instances of the server, and because none of those instances manages the API client’s state, the client can communicate with any of them.