简体   繁体   English

Azure和本地TCP连接数非常不同

[英]Azure and local number of TCP connections are very different

I'm now trying to read data from a lot of Azure blobs in parallel using Azure Function and fail to do so, because my service plan does not allow more than ~4000 TCP connections (which I get an error in the portal about), however when I try to run it locally all of the following: 我现在正试图使用​​Azure功能并行读取大量Azure blob中的数据,但由于我的服务计划不允许超过~4000 TCP连接(我在门户网站中收到错误),但是,当我尝试在本地运行以下所有内容时:

  • netstat with all possible flags 带有所有可能标志的netstat
  • Wireshark Wireshark的
  • TCPView 套装软件
  • network inspector in Windows task manager Windows任务管理器中的网络检查器

just show a couple dozens of items. 只显示几十个项目。 Is there a tool or maybe code snippet which will allow me to emulate locally the situation that I have once my app is deployed? 是否有工具或代码片段允许我在本地模拟我的应用程序部署后的情况?

Even better would be knowing if it is possible to somehow limit the number of TCP connections that my Azure Function is trying to open (using .NET Azure SDK, or Azure portal, or some settings.json file or whatever) 更好的是知道是否有可能以某种方式限制我的Azure功能尝试打开的TCP连接数(使用.NET Azure SDK,或Azure门户,或某些settings.json文件或其他)

Edit1 : I've rewritten the whole thing to be sequential and also I've split blob reads into chunks of 100 items, this seemed to somewhat help the number of TCP connections (it's about 500 at peak now, so still a lot, but at least fitting the app service plan, the app, of course, became slow as hell as a result), but it still tries to allocate ~4000 of "Socket handles" and fails, still can't find a way to see locally the same amount of socket handles allocated - Handles column is Details tab of windows task manager shows roughly the same amount of handles during the whole process execution 编辑1 :我已经把整个事情重写为顺序,并且我将blob读取分成了100项目的块,这似乎有点帮助了TCP连接的数量(现在它的峰值大约为500 ,所以仍然很多,但是至少适合应用服务计划,应用程序,当然,结果变得缓慢),但它仍然试图分配~4000的“套接字句柄”并失败,仍然找不到一种方法来看到本地分配相同数量的套接字句柄 - Handles列是Windows任务管理器的Details选项卡在整个过程执行期间显示大致相同数量的handles

To answer the question itself: I wasn't able to find a way to see locally the TCP-related metrics that I get when actually running my functions in Azure. 回答问题本身:我无法找到一种方法来本地查看在Azure中实际运行我的函数时获得的TCP相关指标。 For now it feels like some important development tools and/or docs are missing. 目前感觉缺少一些重要的开发工具和/或文档。 The "serverless" experience turned out be the deepest dive into Windows system programming I ever had as a .NET developer. “无服务器”体验成为我作为.NET开发人员所拥有的最深入的Windows系统编程。

The solution for the problem itself was the following: I've rewritten the whole thing to be sequential and managed it to get establishing about a hundred simultaneous connections. 问题本身的解决方案如下:我已经将整个事情重写为顺序并管理它以建立大约一百个同时连接。 Then I just used binary search playing with MaxDegreeOfParallelism until I found a value suitable for my plan. 然后我只使用MaxDegreeOfParallelism进行二元搜索,直到找到适合我计划的值。

You may be bumping up against the HTTP standard implementation within HttpClient which restricts the number of open connections to 2 by default. 您可能会遇到HttpClient中的HTTP标准实现,默认情况下会将打开的连接数限制为2。 The HTTP/1.1 specification limits the number of connections from an application to two connections per server. HTTP / 1.1规范将应用程序的连接数限制为每台服务器两个连接。 You can override that default using the DefaultConnectionLimit property of the ServicePointManager. 您可以使用ServicePointManager的DefaultConnectionLimit属性覆盖该默认值。 Microsoft has an article on it here . 微软在这里有一篇文章

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

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