- Mastering Node.js(Second Edition)
- Sandro Pasquali Kevin Faaborg
- 210字
- 2021-07-02 19:28:42
Queueing
In order to avoid overwhelming anyone, we might add a buffer between the clients and the dispatcher. This new worker is responsible for managing customer relations. Instead of speaking directly with the dispatcher, the client speaks to the services manager, passing the manager requests, and at some point in the future, getting a call that their task has been completed. Requests for work are added to a prioritized work queue (a stack of orders with the most important one on top), and this manager waits for another client to walk through the door.
The following figure describes the situations:

The dispatcher tries to keep all workers busy by pulling tasks from this queue, passing back any packages workers have completed, and generally maintaining a sane work environment where nothing gets dropped or lost. Rather than proceeding task-by-task along a single timeline, multiple simultaneous jobs, on their own timelines, run in parallel. If it comes to a point where all the workers are idle and the task queue is empty, the office can sleep for a while, until the next client arrives.
This is a rough schematic of how Node gains speed by working asynchronously, rather than synchronously. Now, let's pe deeper into how Node's event loop works.
- 高校網絡道德教育研究
- Building Django 2.0 Web Applications
- TCP/IP入門經典(第5版)
- 信息通信網絡建設安全管理概要2
- PLC、現場總線及工業網絡實用技術速成
- 世界互聯網發展報告·2019
- 企業網絡安全管理
- 網管員必讀:網絡管理(第2版)
- Windows Server 2012 Hyper-V虛擬化管理實踐
- React Cookbook
- Intelligent Mobile Projects with TensorFlow
- Building Microservices with Spring
- 物聯網商業設計與案例
- Hands-On Microservices:Monitoring and Testing
- 現場總線與工業以太網及其應用技術(第2版)