ajax ashx ihttpasynchandler,asp.net - IIS 7.0 503 errors with generic handler (.ashx) implementing I...

博主在使用实现IHttpAsyncHandler的通用处理器时遇到性能问题,当并发请求达到约5000次时,服务器返回503错误。在同步模式下问题消失。已经尝试调整多种IIS设置,如QueueLength,但无法突破5000并发请求的限制。问题可能与IIS的请求队列限制有关,寻求解决方案以处理更多并发异步请求。负载生成器代码显示了请求发送方式。
摘要由CSDN通过智能技术生成

I'm running into some performance issues using a generic handler that implements IHttpAsyncHandler. At its simplest, the handler receives a GET request, and 20 seconds later ends the response after writing '< timeout / >' to the response.

When hammering the .ashx with 10000-20000 simultaneous requests, it fails with 503 server unavailable after precisely 5000 requests. When switching to synchronous mode, and ending the request immediately, the problem goes away.

I've tinkered with a number of settings, yet the only thing I've managed to acheive is lower the request threshold at which this error occurs.

Here's a rundown of the settings I've toyed with:

machine.config:

...

...

...

web.config:

...

...

...

IIS Manager > ApplicationPools > Advanced Settings

Queue Length : 65535

Although I can't be sure, it seems like these settings work good and fine if the requests are synchronous, but when async, I can't seem to get beyond exactly 5000 requests before the server starts telling me to go away. If I set things lower (can't remember exactly which setting that would be from the above, but I've tried them all), then the 503 count goes up accordingly, but I can never stop it happening beyond 5000 when under serious load.

It seems that there a a number of settings scattered in a myriad of places that might affect this, but the 5000 seems fairly set in stone. I see here that appRequestQueueLimit cannot exceed 5000, but can find no further info about this, and wonder if this is misinformation.

Is there any kind of "flood-control" setting in IIS that might be limiting a single host to no more than 5000 requests? How can I get IIS to handle more that 5000 concurrent asynchronous requests?

Edit2: Are there any counters or other indicators of which limit might be being exceeded, and how would I investigate further?

Edit: Here's the loadgenerator code:

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));

}

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值