简体   繁体   English

这是可扩展的命名管道服务器实现吗?

[英]Is this a scaleable named pipe server implementation?

Looking at this example of named pipes using Overlapped I/O from MSDN, I am wondering how scaleable it is? 看一下使用MSDN中的重叠I / O命名管道的示例,我想知道它的可伸缩性如何? If you spin up a dozen clients and have them hit the server 10x/sec, with each batch of 10 being immediately after the other, before sleeping for a full second, it seems that eventually some of the instances of the client are starved. 如果您启动一打客户机,然后让它们以10x / sec的速度命中服务器,每10个客户机紧接一个,则在休眠一整秒钟之前,似乎最终客户机的某些实例将饿死。

Server implementation: http://msdn.microsoft.com/en-us/library/aa365603%28VS.85%29.aspx 服务器实施: http : //msdn.microsoft.com/zh-cn/library/aa365603%28VS.85%29.aspx

Client implementation (assuming call is made 10x/sec, and there are a dozen instances). 客户端实现(假设调用速度为10x / sec,并且有十几个实例)。 http://msdn.microsoft.com/en-us/library/aa365603%28VS.85%29.aspx http://msdn.microsoft.com/zh-cn/library/aa365603%28VS.85%29.aspx

The fact that the web page points out that: 该网页指出的事实是:

  • The pipe server creates a fixed number of pipe instances. 管道服务器创建固定数量的管道实例。

and

  • Although the example shows simultaneous operations on different pipe instances, it avoids simultaneous operations on a single pipe instance by using the event object in the OVERLAPPED structure. 尽管该示例显示了在不同管道实例上的同时操作,但是通过使用OVERLAPPED结构中的事件对象,它避免了在单个管道实例上的同时操作。 Because the same event object is used for read, write, and connect operations for each instance, there is no way to know which operation's completion caused the event to be set to the signaled state for simultaneous operations using the same pipe instance 因为同一事件对象用于每个实例的读取,写入和连接操作,所以无法知道哪个操作的完成导致事件被设置为使用同一管道实例进行同时操作的信号状态

you can probably safely assume that it's not as scalable as it could be; 您可能可以放心地假设它的扩展性不尽如人意; it's an API usage example after all; 毕竟,这是一个API使用示例; demonstration of functionality is usually the most important design constraint for such code. 功能演示通常是此类代码最重要的设计约束。

If you need 12 clients making 10 connections per second then I'd personally have the server able to handle MORE than just 12 clients to allow for the period when the server is preparing for a new client to connect... Personally I'd switch to using sockets but that's just me (and I'm skewed that way because I've done lots of high performance socket's work and so have all the code)... 如果您需要12个客户端每秒建立10个连接,那么我个人将使服务器能够处理的不仅仅是12个客户端,以便在服务器准备新客户端连接的这段时间内...个人而言,我会切换使用套接字,但这只是我(我歪斜了,因为我已经完成了许多高性能套接字的工作,并且拥有所有代码)...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM