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.
我有一个ASP。NET 4.0应用程序运行在IIS 7.5上,运行在64位Windows Server 2008 R2企业计算机上,具有RAM、CPU、磁盘等功能。
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.
对于每一个web请求,ASP。NET应用程序将连接到后端web服务(通过原始套接字),该服务在同一台机器上运行。
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.
问题:似乎有一些东西限制到后端web服务的同时连接的#。可疑的是,并发连接的数量在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
我找到了微软的这篇关键文章,解释了如何调整IIS的设置以适应ASP。发出大量web服务请求的NET应用程序: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.
我遵循了这篇文章的推荐信,但仍然没有运气。特别有趣的设置是maxconnection设置,我甚至把它改成了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.
注意:当我将IIS从mix中删除,并让客户端直接连接到后端web服务时,它将愉快地打开尽可能多的连接,所以我确信后端并不是瓶颈。它必须是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
):
这是机器的相关部分。我确信应用程序正在读取的配置(通过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>
7 个解决方案
#1
92
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.
这里提供的大多数答案都涉及到后端web服务的传入请求数量,而不是从ASP.net应用程序到后端服务的传出请求数量。
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).
不是后端web服务限制了您的请求率,而是您的调用应用程序愿意建立到相同端点(相同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.
你当然可以选择一个更合理的数字,如果你喜欢50或100个并发连接。但是上面的选项会直接打开给max看。您还可以为上面的open limit规则指定一个特定的地址,而不是表示所有地址的“*”。
MSDN Documentation for System.Net.connectionManagement
MSDN文档System.Net.connectionManagement
Another Great Resource for understanding ConnectManagement in .NET
另一个了解。net中的ConnectManagement的好资源
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!
编辑:糟糕,我确实看到您在上面的代码中提到了连接管理。我将留下我上面的信息,因为它是相关的未来询问者有同样的问题。但是,请注意,目前有4台不同的机器。大多数最新服务器上的配置文件!
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:
有。net Framework v2在32位和64位下运行,还有。net Framework v4也在32位和64位下运行。根据您为应用程序池选择的设置,您可以使用这4台不同机器中的任何一台。配置文件!请检查4台机器。配置文件通常位于这里:
- C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
- C:\Windows\ Microsoft.NET \ Framework \ v2.0.50727 \配置
- C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG
- C:\Windows\ Microsoft.NET \ Framework64 \ v2.0.50727 \配置
- C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
- C:\Windows\ Microsoft.NET \ Framework \ v4.0.30319 \配置
- C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config
- C:\Windows\ Microsoft.NET \ Framework64 \ v4.0.30319 \配置
#2
5
Might it be possible that you're using a WCF-based web service reference? By default, the ServiceThrottlingBehavior.MaxConcurrentCalls is 16.
您是否可能使用基于wcf的web服务引用?默认情况下,ServiceThrottlingBehavior。MaxConcurrentCalls是16。
You could try updating your service reference behavior's <serviceThrottling>
element
您可以尝试更新您的服务引用行为的
<serviceThrottling
maxConcurrentCalls="999"
maxConcurrentSessions="999"
maxConcurrentInstances="999" />
(Note that I'd recommend the settings above.) See MSDN for more information how to configure an appropriate <behavior>
element.
(注意,我推荐以上的设置。)有关如何配置适当的
#3
5
I realize the question might be rather old, but you say the backend is running on the same server. That means on a different port, probably other than the default port 80.
我意识到这个问题可能有些过时了,但是您说后端在同一台服务器上运行。这意味着在另一个端口上,可能除了默认端口80之外。
I've read that when you use the "connectionManagement" configuration element, you need to specify the port number if it differs from the default 80.
我已经看到,当您使用“connectionManagement”配置元素时,如果端口号与默认的80不同,您需要指定端口号。
LINK: maxConnection setting may not work even autoConfig = false in ASP.NET
链接:maxConnection设置在ASP.NET中可能不工作,甚至自动配置= false
Secondly, if you choose to use the default configuration (address="*") extended with your own backend specific value, you might consider putting the specific value first! Otherwise, if a request is made, the * matches first and the default of 2 connections is taken. Just like when you use the section in web.config.
其次,如果您选择使用扩展后端特定值的默认配置(address="*"),您可以考虑将特定值放在前面!否则,如果发出请求,将首先匹配*,并接受2个连接的默认值。就像在web.config中使用section一样。
LINK: <remove> Element for connectionManagement (Network Settings)
链接: <删除用于连接管理的> 元素(网络设置)
Hope it helps someone.
希望它能帮助一些人。
#4
3
Have you tried to set the value of the static DefaultConnectionLimit property programmatically?
您是否试图以编程方式设置静态DefaultConnectionLimit属性的值?
Here is a good source of information about that true headache... ASP.NET Thread Usage on IIS 7.5, IIS 7.0, and IIS 6.0, with updates for framework 4.0.
这是关于真正的头痛的一个很好的信息来源……ASP。iis7.5、iis7.0和iis6.0上的线程使用,框架4.0进行了更新。
#5
2
See the "Threading" section of this page: http://msdn.microsoft.com/en-us/library/ff647786.aspx, in conjunction with the "Connections" section.
请参阅本页面的“线程”部分:http://msdn.microsoft.com/en-us/library/ff647786.aspx,以及“连接”部分。
Have you tried upping the maxconnection attribute of your processModel setting?
您是否尝试过升级processModel设置的maxconnection属性?
#6
0
If it is not defined in the web service or application or server (apache or IIS) that is hosting the web service consumable then you could create infinite connections until failure
如果在托管web服务可消费的web服务或应用程序或服务器(apache或IIS)中没有定义,那么您可以创建无限连接,直到失败
#7
0
while doing performance testing, the measure i go by is RPS, that is how many requests per second can the server serve within acceptable latency.
在进行性能测试时,我使用的度量是RPS,即服务器在可接受的延迟内每秒可以服务多少请求。
theoretically one server can only run as many requests concurrently as number of cores on it..
从理论上讲,一台服务器只能同时运行与它上的内核数量相同的请求。
It doesn't look like the problem is ASP.net's threading model, since it can potentially serve thousands of rps. It seems like the problem might be your application. Are you using any synchronization primitives ?
它看起来不像ASP.net的线程模型,因为它可能提供数千个rps。看起来问题可能是你的应用程序。您是否使用了任何同步原语?
also whats the latency on your web services, are they very quick to respond (within microseconds), if not then you might want to consider asynchronous calls, so you dont end up blocking
另外,web服务的延迟是什么,它们会很快响应(在微秒内),如果不是这样,您可能需要考虑异步调用,所以您不会阻塞。
If this doesnt yeild something, then you might want to profile your code using visual studio or redgate profiler
如果这不能说明什么,那么您可能需要使用visual studio或redgate profiler对代码进行配置
#1
92
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.
这里提供的大多数答案都涉及到后端web服务的传入请求数量,而不是从ASP.net应用程序到后端服务的传出请求数量。
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).
不是后端web服务限制了您的请求率,而是您的调用应用程序愿意建立到相同端点(相同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.
你当然可以选择一个更合理的数字,如果你喜欢50或100个并发连接。但是上面的选项会直接打开给max看。您还可以为上面的open limit规则指定一个特定的地址,而不是表示所有地址的“*”。
MSDN Documentation for System.Net.connectionManagement
MSDN文档System.Net.connectionManagement
Another Great Resource for understanding ConnectManagement in .NET
另一个了解。net中的ConnectManagement的好资源
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!
编辑:糟糕,我确实看到您在上面的代码中提到了连接管理。我将留下我上面的信息,因为它是相关的未来询问者有同样的问题。但是,请注意,目前有4台不同的机器。大多数最新服务器上的配置文件!
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:
有。net Framework v2在32位和64位下运行,还有。net Framework v4也在32位和64位下运行。根据您为应用程序池选择的设置,您可以使用这4台不同机器中的任何一台。配置文件!请检查4台机器。配置文件通常位于这里:
- C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
- C:\Windows\ Microsoft.NET \ Framework \ v2.0.50727 \配置
- C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG
- C:\Windows\ Microsoft.NET \ Framework64 \ v2.0.50727 \配置
- C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
- C:\Windows\ Microsoft.NET \ Framework \ v4.0.30319 \配置
- C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config
- C:\Windows\ Microsoft.NET \ Framework64 \ v4.0.30319 \配置
#2
5
Might it be possible that you're using a WCF-based web service reference? By default, the ServiceThrottlingBehavior.MaxConcurrentCalls is 16.
您是否可能使用基于wcf的web服务引用?默认情况下,ServiceThrottlingBehavior。MaxConcurrentCalls是16。
You could try updating your service reference behavior's <serviceThrottling>
element
您可以尝试更新您的服务引用行为的
<serviceThrottling
maxConcurrentCalls="999"
maxConcurrentSessions="999"
maxConcurrentInstances="999" />
(Note that I'd recommend the settings above.) See MSDN for more information how to configure an appropriate <behavior>
element.
(注意,我推荐以上的设置。)有关如何配置适当的
#3
5
I realize the question might be rather old, but you say the backend is running on the same server. That means on a different port, probably other than the default port 80.
我意识到这个问题可能有些过时了,但是您说后端在同一台服务器上运行。这意味着在另一个端口上,可能除了默认端口80之外。
I've read that when you use the "connectionManagement" configuration element, you need to specify the port number if it differs from the default 80.
我已经看到,当您使用“connectionManagement”配置元素时,如果端口号与默认的80不同,您需要指定端口号。
LINK: maxConnection setting may not work even autoConfig = false in ASP.NET
链接:maxConnection设置在ASP.NET中可能不工作,甚至自动配置= false
Secondly, if you choose to use the default configuration (address="*") extended with your own backend specific value, you might consider putting the specific value first! Otherwise, if a request is made, the * matches first and the default of 2 connections is taken. Just like when you use the section in web.config.
其次,如果您选择使用扩展后端特定值的默认配置(address="*"),您可以考虑将特定值放在前面!否则,如果发出请求,将首先匹配*,并接受2个连接的默认值。就像在web.config中使用section一样。
LINK: <remove> Element for connectionManagement (Network Settings)
链接: <删除用于连接管理的> 元素(网络设置)
Hope it helps someone.
希望它能帮助一些人。
#4
3
Have you tried to set the value of the static DefaultConnectionLimit property programmatically?
您是否试图以编程方式设置静态DefaultConnectionLimit属性的值?
Here is a good source of information about that true headache... ASP.NET Thread Usage on IIS 7.5, IIS 7.0, and IIS 6.0, with updates for framework 4.0.
这是关于真正的头痛的一个很好的信息来源……ASP。iis7.5、iis7.0和iis6.0上的线程使用,框架4.0进行了更新。
#5
2
See the "Threading" section of this page: http://msdn.microsoft.com/en-us/library/ff647786.aspx, in conjunction with the "Connections" section.
请参阅本页面的“线程”部分:http://msdn.microsoft.com/en-us/library/ff647786.aspx,以及“连接”部分。
Have you tried upping the maxconnection attribute of your processModel setting?
您是否尝试过升级processModel设置的maxconnection属性?
#6
0
If it is not defined in the web service or application or server (apache or IIS) that is hosting the web service consumable then you could create infinite connections until failure
如果在托管web服务可消费的web服务或应用程序或服务器(apache或IIS)中没有定义,那么您可以创建无限连接,直到失败
#7
0
while doing performance testing, the measure i go by is RPS, that is how many requests per second can the server serve within acceptable latency.
在进行性能测试时,我使用的度量是RPS,即服务器在可接受的延迟内每秒可以服务多少请求。
theoretically one server can only run as many requests concurrently as number of cores on it..
从理论上讲,一台服务器只能同时运行与它上的内核数量相同的请求。
It doesn't look like the problem is ASP.net's threading model, since it can potentially serve thousands of rps. It seems like the problem might be your application. Are you using any synchronization primitives ?
它看起来不像ASP.net的线程模型,因为它可能提供数千个rps。看起来问题可能是你的应用程序。您是否使用了任何同步原语?
also whats the latency on your web services, are they very quick to respond (within microseconds), if not then you might want to consider asynchronous calls, so you dont end up blocking
另外,web服务的延迟是什么,它们会很快响应(在微秒内),如果不是这样,您可能需要考虑异步调用,所以您不会阻塞。
If this doesnt yeild something, then you might want to profile your code using visual studio or redgate profiler
如果这不能说明什么,那么您可能需要使用visual studio或redgate profiler对代码进行配置