知识卡片
事件模型必须端到端非阻塞
事件模型把一次请求分成不会阻塞的小任务:发出I/O后释放线程,完成事件再排队执行下一任务。少量线程可持续处理有效工作,但任一任务做阻塞I/O或等待锁,都可能占住稀缺事件线程。它因此与非阻塞I/O互相依赖,且把续体、状态和排障复杂度交给实现者;仅把API名字改成异步不保证整条处理链非阻塞。
结构图:
flowchart TD
A[任务开始] --> B[发出非阻塞I/O]
B --> C[释放线程处理其他任务]
B --> D[I/O完成事件]
D --> E[后续任务入队]
E --> F[可用线程执行后续逻辑]
与[[每请求线程换取简单编程]]相比,事件模型减少等待占用,却增加端到端非阻塞的实现责任。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 服务端架构 · 查看原书依据
For service calls, subitems must use nonblocking I/O operations. After the service call starts, the thread is released to take on new work. When the service call completes, the architecture schedules the next subitem with the service response and adds it to the queue.
参考来源
- 位置:《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)
- 结论依据:摘录说明事件模型把一次请求分成不会阻塞的小任务:发出I/O后释放线程,完成事件再排队执行下一任务。其余条件结合本章相邻例子与取舍说明,数字示例不作当前性能承诺。
- 原始内容:For service calls, subitems must use nonblocking I/O operations. After the service call starts, the thread is released to take on new work. When the service call completes, the architecture schedules the next subitem with the service response and adds it to the queue.