0

我有两个在 IIS 上运行的 C# asp.net 应用程序:主应用程序创建多达 80 个线程,其中每个线程将以大约 3 秒的频率建立到特定端点(所有相同端点 (LAN))的 http 连接。该端点托管在本地主机上(例如本地主机:4510)。该端点是代表“驱动程序”的第二个应用程序,它将最终与 LAN 内的设备建立连接。因此,完全有可能有 80 个线程同时尝试向驱动程序/设备发出请求。

随着时间的推移,该应用程序似乎在涉及 httpclients 的任何事情上都有问题。RavenDB、Elasticsearch 以及 80 个线程。我读了一些关于 ServicePointManager 类的东西;特别是 DefaultConnectionLimit 和 MaxServicePoints 以及如何影响 http 吞吐量。我对底层机制只有基本的了解,所以我想问一下我是否应该专注于特定主题,或者我想要检查的内容可能会提高 http 吞吐量。

更新: 在当前配置下,CPU 负载很低,内存消耗也很低。以下代码显示了 80 个 httpclients 如何连接到 localhost:4510 上的驱动程序:

var driverBaseAddressSp= ServicePointManager.FindServicePoint(driverBaseAddress);                               Debug.WriteLine(driverBaseAddressSp.ConnectionLimit);
Debug.WriteLine(driverBaseAddressSp.MaxIdleTime);
var connectionUriSp = ServicePointManager.FindServicePoint(connectionUri);
Debug.WriteLine(connectionUriSp.ConnectionLimit);
Debug.WriteLine(connectionUriSp.MaxIdleTime);
return new HttpClient { BaseAddress = driverBaseAddress }; 

ConnectionLimit 在调试时显示 Int.Max 但我在解决方案中找不到任何配置?

4

0 回答 0