官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 莫力| 南宁市| 龙泉市| 巴塘县| 肇东市| 兴文县| 洱源县| 合江县| 大英县| 江北区| 云南省| 郁南县| 富顺县| 霍邱县| 泾阳县| 义马市| 青阳县| 恭城| 济宁市| 馆陶县| 日喀则市| 揭西县| 财经| 理塘县| 南皮县| 中山市| 砚山县| 祁连县| 尉犁县| 龙江县| 岱山县| 和平县| 安多县| 昂仁县| 贵定县| 论坛| 客服| 古交市| 繁峙县| 安平县| 冀州市|