← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 5382

服务内状态应能重建

理解等级:中级

服务尽量无状态;必须保留的内存状态应在重启后可重建,例如缓存、池和索引。也可让客户端随请求提供必要上下文,减少实例间会话绑定,但不能因此省掉服务端验证。重建能力简化扩容与恢复,持久业务状态仍需要可靠存储;不要把无法恢复的唯一事实只留在进程内存。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 服务端架构 · 查看原书依据

      Handling state within a service is complex. Write stateless services when you can and keep as little state as possible if you must keep it in the service. One way of doing this is to ask clients to remember and send the state with each request (e.g., using cookies).

    参考来源

    - 位置:《Software Architecture and Decision-Making》第11章《Server Architectures》(来源项目:book-sources;源文件:extracted/Software Architecture and Decision-Making Leveraging Leadership, Technology, and Product Management to Build Great Products… (Srinath Perera)/_epub-src/ch11.xhtml) - 结论依据:摘录说明服务尽量无状态;必须保留的内存状态应在重启后可重建,例如缓存、池和索引。其余条件结合本章相邻例子与取舍说明,数字示例不作当前性能承诺。 - 原始内容:Handling state within a service is complex. Write stateless services when you can and keep as little state as possible if you must keep it in the service. One way of doing this is to ask clients to remember and send the state with each request (e.g., using cookies).