知识卡片
事件循环避免长时间占用
事件循环适合让等待I/O的请求交错推进,但长时间CPU任务占据执行线程会阻塞其他事件。线程与协程模型也受队列、内存和下游容量限制;调用同步与否和底层线程模型是不同维度,不能按语言二分。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Choosing Platform and Technologies · 查看原书依据
Event loop model (Node.js): Node.js and frameworks like Express take a different approach. They use a single thread that processes events in a loop. When a request comes in, it is processed asynchronously without blocking the main thread.
参考来源
- 位置:《Building Distributed Systems Designing scalable architectures with microservices, event-driven patterns, and robust deployment…》第12章《Choosing Platform and Technologies》(来源项目book-sources;源文件:extracted/Building Distributed Systems Designing scalable architectures with microservices, event-driven patterns, and robust deployment…/_epub-src/OPS/ch12.xhtml)
- 结论依据:原文的机制或对比支持以下核心判断:事件循环适合让等待I/O的请求交错推进,但长时间CPU任务占据执行线程会阻塞其他事件。 本卡将相邻说明中的适用限制保留为解释。
- 原始内容:Event loop model (Node.js): Node.js and frameworks like Express take a different approach. They use a single thread that processes events in a loop. When a request comes in, it is processed asynchronously without blocking the main thread.