spe*_*der 7 asp.net iis-7 ashx ihttpasynchandler http-status-code-503
我使用实现IHttpAsyncHandler的通用处理程序遇到了一些性能问题.最简单的是,处理程序接收GET请求,20秒后在响应中写入"<timeout />"后结束响应.
当使用10000-20000个并发请求锤击.ashx时,在准确的5000个请求之后,503服务器不可用.切换到同步模式并立即结束请求时,问题就消失了.
我已经修改了许多设置,但我唯一能够实现的是降低发生此错误的请求阈值.
这是我玩过的设置的简要说明:
machine.config中:
<configuration>
...
<system.web>
...
<processModel enable="true" requestQueueLimit="10000"/>
...
Run Code Online (Sandbox Code Playgroud)
web.config中:
<configuration>
...
<system.web>
...
<httpRuntime enable="true" appRequestQueueLimit="10000"/>
...
Run Code Online (Sandbox Code Playgroud)
IIS管理器> ApplicationPools>高级设置
Queue Length : 65535
Run Code Online (Sandbox Code Playgroud)
虽然我不能确定,但是如果请求是同步的,那么这些设置似乎工作正常,但是当异步时,在服务器开始告诉我离开之前,我似乎无法超越5000个请求.如果我把事情设置得更低(不能确切地记住上面的设置,但我已经尝试了所有设置),那么503计数会相应地上升,但是当负载严重时我永远不能阻止它超过5000 .
似乎有很多设置分散在无数的地方可能会影响到这一点,但5000似乎相当固定.我在这里看到appRequestQueueLimit不能超过5000,但是找不到关于此的更多信息,并想知道这是否是错误的信息.
IIS中是否存在任何类型的"泛滥控制"设置,可能会将单个主机限制为不超过5000个请求?如何让IIS处理更多5000个并发异步请求?
编辑2:是否有任何计数器或其他指标可能超出限制,我将如何进一步调查?
编辑:这是loadgenerator代码:
using System;
using System.Net;
using System.Threading;
namespace HammerTime
{
class Program
{
private static int counter = 0;
static void Main(string[] args)
{
var limit = 5000;
ServicePointManager.DefaultConnectionLimit=limit;
for (int i = 0; i < limit;++i )
{
StartWebRequest(i.ToString());
}
Console.ReadLine();
}
private static void StartWebRequest(string channelId)
{
string uri = "http://spender2008/test/Test.ashx?channel="+channelId;
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri);
request.BeginGetResponse(responseHandler, request);
}
private static void responseHandler(IAsyncResult ar)
{
try
{
HttpWebRequest state = (HttpWebRequest)ar.AsyncState;
HttpWebResponse response = (HttpWebResponse)state.EndGetResponse(ar);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
Console.WriteLine(Interlocked.Increment(ref counter));
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
好.修复...非常感谢这篇帖子清理了一些细节.
要消除503错误,需要3个不同的配置更改:
machine.config中:
<configuration>
...
<system.web>
...
<processModel enable="true" requestQueueLimit="100000"/>
Run Code Online (Sandbox Code Playgroud)
IIS管理器> ApplicationPools>高级设置
Queue Length : 65535
Run Code Online (Sandbox Code Playgroud)
最后(拼图的缺失部分),命令行:
appcmd.exe set config /section:serverRuntime /appConcurrentRequestLimit:100000
Run Code Online (Sandbox Code Playgroud)
主帖中提到的web.config设置无关紧要.
10000并发连接,没问题.感谢帮助!
| 归档时间: |
|
| 查看次数: |
13062 次 |
| 最近记录: |