- 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.
- 網(wǎng)絡(luò)云百問(wèn)百答
- 物聯(lián)網(wǎng)智慧安監(jiān)技術(shù)
- C++黑客編程揭秘與防范
- 網(wǎng)管員典藏書架:網(wǎng)絡(luò)管理與運(yùn)維實(shí)戰(zhàn)寶典
- Spring Boot 2.0 Projects
- Building RESTful Web Services with Spring 5(Second Edition)
- Unity Artificial Intelligence Programming
- Master Apache JMeter:From Load Testing to DevOps
- Learning Windows 8 Game Development
- AWS Lambda Quick Start Guide
- 5G技術(shù)核心與增強(qiáng):從R15到R17
- 計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)
- Hands-On Docker for Microservices with Python
- 新IP:面向泛在全場(chǎng)景的未來(lái)數(shù)據(jù)網(wǎng)絡(luò)
- Architecting Data:Intensive Applications