gpt4 book ai didi

sockets - Azure 服务总线、Redis 缓存、队列等中的单个 TCP channel 何时不足

转载 作者:IT王子 更新时间:2023-10-29 06:14:05 25 4
gpt4 key购买 nike

我在很多地方都看到过这种推荐,比如:

Multiple factories: all clients (senders in addition to receivers) that are created by the same factory share one TCP connection. The maximum message throughput is limited by the number of operations that can go through this TCP connection. The throughput that can be obtained with a single factory varies greatly with TCP round-trip times and message size. To obtain higher throughput rates, you should use multiple messaging factories.

您可以为 Redis、RabbitMQ 等找到类似的建议。我的问题是,一个 TCP channel 如何耗尽?我相信单个 TCP channel 没有带宽限制。

那么,为什么人们建议使用多个 channel 来实现高吞吐量?是不是因为:

  1. 如果客户端应用程序向单个 tcp channel 发送大量小消息,则每个操作都会锁定 tcp 套接字,然后发送消息。它可能导致锁争用。如果我们使用多个 tcp channel ,这种争用可以在一定程度上解决。

  2. 如果在 tcp channel 上发送大消息,可能需要一些时间来序列化/反序列化并将其推送到 channel 。它可以阻止其他小消息。

这些是实际原因吗(或者如果这些假设是错误的,真正的原因是什么)?

最佳答案

基本上,你是对的。客户端 1 --> TCP/IP ---> 服务器(做一些处理)现在,客户端 2 想向服务器发送请求?客户端 2 需要等待客户端 1 完成(我假设这里的上下文是关于阻塞 I/O 的)。因此,如果您有多个 TPC 连接,客户端 2 可以与客户端 1 同时发送请求 ==> 增加吞吐量。但它伴随着成本来维持更活跃的连接。您应该确保您有“足够”的连接来满足您的请求,并尽量减少“空闲”连接的数量。

关于sockets - Azure 服务总线、Redis 缓存、队列等中的单个 TCP channel 何时不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39247311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com