是什么限制了同时连接#我的ASP.NET应用程序可以对Web服务? [英] What is limiting the # of simultaneous connections my ASP.NET application can make to a web service?

查看:162
本文介绍了是什么限制了同时连接#我的ASP.NET应用程序可以对Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个64位Windows Server 2008 R2企业版的机器上运行IIS之上7.5采空区的RAM,CPU,硬盘等的ASP.NET 4.0应用程序。

随着每一个Web请求,ASP.NET应用程序,使到后端的Web服务(通过原始套接字)的连接,这是在同一台机器上运行。

问题:似乎有一些限制到后端网络服务的同时连接#。可疑,并发连接数为16平顶。

我发现从微软解释如何调整IIS的设置,以适应ASP.NET应用程序,使大量Web服务请求的这一关键文章:<一href=\"http://support.microsoft.com/?id=821268#tocHeadRef\">http://support.microsoft.com/?id=821268#tocHeadRef

我跟文章的recommendatinos,但仍没有运气。这是特别有趣的设置是 MAXCONNECTION 设置,我甚至碰到至999。

任何想法的其他的可能是节流的连接?

注意::当我剪了IIS的搭配,并有客户端直接连接到后端网络服务,因为我需要它会高兴地打开多个连接,所以我敢肯定后端不是瓶颈。它必须是东西在IIS / ASP.NET土地。

下面是有关节的的machine.config ,我敢肯定,是由应用程序(使用 Appcmd.exe的

 &LT;&的System.Web GT;
    &LT;中processModel AUTOCONFIG =假maxWorkerThreads =100maxIoThreads =100minWorkerThreads =50/&GT;
    &LT;的httpRuntime minFreeThreads =176minLocalRequestFreeThreads =152/&GT;    &LT; HttpHandlers的/&GT;    &LT;会员和GT;
        &LT;供应商&GT;
            &LT;添加名称=AspNetSqlMembershipProvider
                键入=System.Web.Security.SqlMembershipProvider,System.Web程序,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a
                的connectionStringName =LocalSqlServer这个
                enablePasswordRetrieval =假
                enablePasswordReset设置=真
                requiresQuestionAndAnswer =真
                的applicationName =/
                requiresUniqueEmail =假
                了passwordFormat =散列
                maxInvalidPasswordAttempts =5
                minRequiredPasswordLength =7
                minRequiredNonalphanumericCharacters =1
                passwordAttemptWindow =10
                passwordStrengthRegularEx pression =/&GT;
        &LT; /供应商&GT;
    &LT; /会员&GT;    &LT;型材&GT;
        &LT;供应商&GT;
            &LT;添加名称=AspNetSqlProfileProvider的connectionStringName =LocalSqlServer这个的applicationName =/
                键入=System.Web.Profile.SqlProfileProvider,System.Web程序,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a/&GT;
        &LT; /供应商&GT;
    &LT; / profile文件&GT;    &LT; roleManager&GT;
        &LT;供应商&GT;
            &LT;添加名称=AspNetSqlRoleProvider的connectionStringName =LocalSqlServer这个的applicationName =/
                键入=System.Web.Security.SqlRoleProvider,System.Web程序,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a/&GT;
            &LT;添加名称=AspNetWindowsTokenRoleProvider的applicationName =/
                键入=System.Web.Security.WindowsTokenRoleProvider,System.Web程序,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a/&GT;
        &LT; /供应商&GT;
    &LT; / roleManager&GT;
&LT; /system.web>
&LT; system.net&GT;
    &LT; connectionManagement&GT;
        &LT;添加地址=*MAXCONNECTION =999/&GT;
    &LT; / connectionManagement&GT;
&LT; /system.net>


解决方案

大部分这里提供的答案解决的传入的请求的数量,以你的后端Web服务,而不是数量的传出请求的你可以从你的ASP.net应用程序到你的后端服务。

这不,在这里您节流率的要求后端的web服务,它是开放的连接数的调用应用程序是愿意建立到同一个终点(相同的URL)。

您可以通过添加下面的配置部分,将machine.config文件中删除此限制:

 &LT;结构&gt;
  &LT; system.net&GT;
    &LT; connectionManagement&GT;
      &LT;添加地址=*MAXCONNECTION =65535/&GT;
    &LT; / connectionManagement&GT;
  &LT; /system.net>
&LT; /结构&gt;

您当然可以选择一个更合理一些,如果你想如50或100个并发连接。但上面会打开它一直到最大值。您也可以指定一个特定的地址开放限制规则之上,而不是*,表示所有地址。

MSDN文档System.Net.connectionManagement

另一个伟大的资源理解ConnectManagement在.NET

希望这会解决您的问题!

编辑:哎呀,我看你有没有在你的code上面提到的连接管理。我将离开我的上述信息,因为它是相关的同样的问题未来的询问者。但是,请注意目前有大多数4个不同的machine.config文件更新服务器!

有是32位和64位,以及.NET Framework还V4 32位和64位下运行在.NET框架v2的运行。根据您的应用程序池您选择的设置,您可以使用这些4个不同的machine.config文件的任何一个!请检查通常就设在这里的所有4的machine.config文件:


  • C:\\ WINDOWS \\ Microsoft.NET \\框架\\ V2.0.50727 \\ CONFIG

  • C:\\ WINDOWS \\ Microsoft.NET \\ Framework64 \\ V2.0.50727 \\ CONFIG

  • C:\\ WINDOWS \\ Microsoft.NET \\框架\\ v4.0.30319 \\ Config中

  • C:\\ WINDOWS \\ Microsoft.NET \\ Framework64 \\ v4.0.30319 \\ Config中

I have an ASP.NET 4.0 application running atop IIS 7.5 on a 64-bit Windows Server 2008 R2 Enterprise machine with gobs of RAM, CPU, disk, etc.

With every web request, the ASP.NET application makes a connection to a backend web service (via raw sockets), which is running on the same machine.

Problem: There appears to be something limiting the # of simultaneous connections to the backend web service. Suspiciously, the number of concurrent connections is topping out at 16.

I found this key article from Microsoft explaining how to tweak IIS' settings to accomodate ASP.NET apps that make lots of web service requests: http://support.microsoft.com/?id=821268#tocHeadRef

I followed the article's recommendatinos, but still no luck. The setting that is particularly interesting is the maxconnection setting, which I even bumped to 999.

Any ideas what else could be throttling connections?

Note: When I cut IIS out of the mix and have the clients connect directly to the backend web service, it will happily open as many connections as I need, so I'm positive the backend is not the bottleneck. It must be something in IIS/ASP.NET-land.

Here's the relevant section of the machine.config which I'm sure is being read by the application (verified with appcmd.exe):

<system.web>
    <processModel autoConfig="false" maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50" />
    <httpRuntime minFreeThreads="176" minLocalRequestFreeThreads="152"/>

    <httpHandlers />

    <membership>
        <providers>
            <add name="AspNetSqlMembershipProvider"
                type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                connectionStringName="LocalSqlServer"
                enablePasswordRetrieval="false"
                enablePasswordReset="true"
                requiresQuestionAndAnswer="true"
                applicationName="/"
                requiresUniqueEmail="false"
                passwordFormat="Hashed"
                maxInvalidPasswordAttempts="5"
                minRequiredPasswordLength="7"
                minRequiredNonalphanumericCharacters="1"
                passwordAttemptWindow="10"
                passwordStrengthRegularExpression="" />
        </providers>
    </membership>

    <profile>
        <providers>
            <add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/"
                type="System.Web.Profile.SqlProfileProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
    </profile>

    <roleManager>
        <providers>
            <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/"
                type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            <add name="AspNetWindowsTokenRoleProvider" applicationName="/"
                type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
    </roleManager>
</system.web>
<system.net>
    <connectionManagement>
        <add address="*" maxconnection="999"/>
    </connectionManagement>
</system.net>

解决方案

Most of the answers provided here address the number of incoming requests to your backend webservice, not the number of outgoing requests you can make from your ASP.net application to your backend service.

It's not your backend webservice that is throttling your request rate here, it is the number of open connections your calling application is willing to establish to the same endpoint (same URL).

You can remove this limitation by adding the following configuration section to your machine.config file:

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

You could of course pick a more reasonable number if you'd like such as 50 or 100 concurrent connections. But the above will open it right up to max. You can also specify a specific address for the open limit rule above rather than the '*' which indicates all addresses.

MSDN Documentation for System.Net.connectionManagement

Another Great Resource for understanding ConnectManagement in .NET

Hope this solves your problem!

EDIT: Oops, I do see you have the connection management mentioned in your code above. I will leave my above info as it is relevant for future enquirers with the same problem. However, please note there are currently 4 different machine.config files on most up to date servers!

There is .NET Framework v2 running under both 32-bit and 64-bit as well as .NET Framework v4 also running under both 32-bit and 64-bit. Depending on your chosen settings for your application pool you could be using any one of these 4 different machine.config files! Please check all 4 machine.config files typically located here:

  • C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
  • C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG
  • C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
  • C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config

这篇关于是什么限制了同时连接#我的ASP.NET应用程序可以对Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆