freeCodeCamp/guide/chinese/computer-science/evented-servers/index.md

19 lines
1.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Evented Servers
localeTitle: 偶像服务器
---
## 偶像服务器
Evented服务器运行单个事件循环处理所有连接客户端的事件。这与使用多个并发执行线程的线程服务器相对每个线程处理一个客户端请求。
简单来说Evented服务器只有一个主线程在所有客户端请求之间共享。 Evented服务器的特殊之处在于他们可以优先处理客户请求所需的工作。 我们将通过一个例子说明这一点。
假设您是出租车公司的所有者(让它被称为服务器),并且您有人打电话给您的公司(让他们称为客户),他们想要安排取件(让那些被称为请求)。您雇用运营商(让他们称为流程/线程)来接受客户的订单。您的业​​务逻辑表明您的运营商必须保持在线,直到将出租车司机发送到客户端为止。从本质上讲,您可能希望雇用与您可以派遣的驾驶员驾驶员数量一样多的操作员。
使用Evented服务器只有一个操作员能够从客户那里获取提取详细信息但是一旦将出租车司机发送给他就知道要回叫客户。
这些类型的服务器使用回调来让客户知道他们的请求何时被处理。
#### 更多信息:
[维基百科上的偶数驱动架构](https://en.wikipedia.org/wiki/Event-driven_architecture)