我正在编写一个应用程序,其中有许多(数百)个并发网络操作在两个实例之间并行运行。由于连接的平均生存期很短(最多几秒钟),我认为使用许多TCP连接并每次进行握手(特别是TLS握手)的开销太大。
我开始研究一些实现多路复用的协议和库(主要是AMQP实现,如Apache Qupid、RabbitMQ,如this question的答案中所提到的)。然而,它们似乎都运行在TCP之上,这引入了一些开销,并且没有太多意义(this post很好地解释了这个问题,并得出TCP多路复用是愚蠢的结论)。而且它们都感觉很胖,我更喜欢小而轻的东西(不幸的是ZeroMQ没有实现多路复用afaik)。这让我开始思考是否可以选择使用UDP。当然,人们必须正确地实现恢复和ACK之类的东西,但要了解连接上的多数据流,这应该比简单地使用TCP更有效。
你认为我上面的推理是正确的,还是我错过了什么重要的东西?有没有好的C/C++库可以通过UDP实现多路复用?
发布于 2012-11-06 22:03:02
做可能工作的最简单的事情,只有在必要的时候才让它变得更复杂:
- if these logical entities are just asynchronous request/response pairs, for example, you may be able to dispense with explicit logical sessions entirely
- first consider just capping the number of outstanding requests/active sessions on the sending side, instead of requiring a specific ack
- only if you need to dynamically vary queue length (eg. because you're really trying to limit working memory, which varies by session) use an explicit logical ack for this
。
https://stackoverflow.com/questions/13251925
复制相似问题