为什么用的Http请求提琴手是速度极快极快、什么用、速度、提琴手

2023-09-03 02:33:25 作者:桃花快开了吧

我写在C#中的多线程程序,抓取一个网站,但是当我在后台请求启动提琴手完成12倍的速度更快,这对我来说真的很奇怪,当我关闭小提琴手下载速率减缓起伏。它是如何可能请大家帮忙,(有没有代理服务器设置我的连接到INETERNET和提琴手也是如此),如果我能注入小提琴手在我的应用程序的性能,那就太好了,解决的办法?有没有幕后的任何魔法? :)

I wrote a multithread program in c# that crawls a web site, but when I started Fiddler in the background request completed 12x faster, it is really strange for me and when I close Fiddler download rates slows downs. how it is possible please help, (there is no proxy setting for my connection to the ineternet and for Fiddler too) If i can inject the performance of fiddler in my application it would be wonderful, any solution? Is there any magic behind the scenes ?? :)

感谢

推荐答案

原因是其使用招时,忽略的HTTP连接数限制的数量。

The reason is the number of http connections limit which is ignored when using fiddler.

我在使用 System.Net.Http.HttpClient 来执行多个(〜80)的并发请求遇到相同的行为。随着小提琴手已经开始所有的请求都完成得更快。保持活动也绝对启用。

I encountered the same behavior while using System.Net.Http.HttpClient to perform multiple (~80) concurrent requests. With fiddler having started all the requests were completing much faster. Keep-alive was certainly enabled.

我用Wireshark来看看发生了什么以及我首先注意到的是,HTTP流量的方式是不同的。随着小提琴手的请求被扔一次全部,之后随之而来的反应很好地groupped为好。虽然没有提琴手的请求,均与交错的响应。

I used wireshark to see what's happening and first thing I noticed that the manner of the http traffic was different. With fiddler requests were thrown all at once and after that responses followed nicely groupped as well. While without fiddler the requests were interleaving with responses.

其次,TCPView的表明我没有小提琴手code为创建只有2个TCP连接到服务器。而事实证明,有fillder各地大幅增加的连接数。有几十人,从我的应用程序提琴手,然后从小提琴手到服务器。

Secondly, tcpview showed that my code without fiddler is creating only 2 tcp connections to a server. And it turned out that having fillder around drastically increased the number of connections. There were tens of them from my app to fiddler and then from fiddler to a server.

有公知的是HTTP标准建议http连接的数量应不超过2并且限制被实现为在最HTTP客户机默认设置。

It is well known that the http standard recommends the number of http connections should not be more than 2 and the limit is implemented as a default setting in most http clients.

在.NET应用程序中,我们可以控制与 ServicePointManager.DefaultConnectionLimit 静态属性的限制。作为实验,已经将其设置为100取得执行相同的速度有或没有提琴手请求。

In .net applications we can control the limit with ServicePointManager.DefaultConnectionLimit static property. As an experiment, having set it to 100 made the requests executing the same speed with or without fiddler.

的设定也可通过控​​制的app.config:

The setting can also be controlled through app.config:

    <system.net>
    <connectionManagement>
        <add address="*" maxconnection="100" />
    </connectionManagement>
</system.net>

现在为什么是同时使用招不尊重的默认连接限制。原来,使用http客户端时的代理和提琴手不充当代理的限制是不同的。我没有找到有关除了代理连接数限制这个老文章。

Now why is the default connection limit not respected while using fiddler. It turned out the limit is different when http client using a proxy and fiddler does act as a proxy. I did not find much information about the proxy connection limit besides this old article.

 
精彩推荐