Modifying the ASP.NET Request Queue Limit
当查询 ASP.NET 时,服务请求会通过一个管道从 Internet Information Services (IIS) 传递到 ASP.NET 工作进程,并在该管道中排队。(ASP.NET 运行在自己的进程中 —— 这与经典 ASP 不同,后者与 IIS 服务运行在同一进程中。)默认情况下,该队列最多只能容纳 5000 个请求。如果请求超过 5000 个,用户将收到 "503 - 服务不可用" 错误,并被拒绝服务。
虽然默认值对于相对较少的 Communicator Web Access (2007 R2 版本) 用户来说是足够的,但随着用户数量接近 4500 时,请求队列的限制可能会轻易被超越。因此,你可能需要将请求队列的限制提高到 15,000。这可以通过编辑 .NET Framework 的 machine.config
文件来实现。将请求队列限制设置为 15,000,可以提供一个足够大的队列,以处理所有客户端请求。此外,如果服务器运行在 Windows Server 2008 上,你还需要配置 appConcurrentRequestLimit
设置,以支持超过 5000 个连接。
修改 ASP.NET 请求队列限制的步骤:
- 点击 开始,然后点击 运行。
- 在 运行 对话框中,输入以下内容:
notepad %systemroot%\Microsoft.Net\Framework64\v2.0.50727\CONFIG\machine.config
,然后点击 确定。 - 定位到如下的
processModel
元素:
<processModel autoConfig="true" />
- 将
processModel
元素替换为以下内容:
<processModel enable="true" requestQueueLimit="15000" />
- 保存并关闭
Machine.config
文件。
对于 Windows Server 2008,执行以下操作:
在 运行 对话框中,输入以下命令:
appcmd.exe set config /section:serverRuntime /appConcurrentRequestLimit:<#of users * 1.5>
具体设置如下:
1. 调整IIS 7应用程序池队列长度
由原来的默认1000改为65535。
IIS Manager > ApplicationPools > Advanced Settings
Queue Length : 65535
2. 调整IIS 7的appConcurrentRequestLimit设置
由原来的默认5000改为100000。
c:\windows\system32\inetsrv\appcmd.exe set config /section:serverRuntime /appConcurrentRequestLimit:100000
在%systemroot%\System32\inetsrv\config\applicationHost.config中可以查看到该设置:
< serverRuntime appConcurrentRequestLimit ="100000" />
3. 调整machine.config中的processModel>requestQueueLimit的设置
由原来的默认5000改为100000。
<configuration> <system.web> <processModel enable="true" requestQueueLimit="100000"/>
参考文章:http://technet.microsoft.com/en-us/library/dd425294(office.13).aspx
4. 修改注册表,调整IIS 7支持的同时TCPIP连接数
由原来的默认5000改为100000。
reg add HKLM\System\CurrentControlSet\Services\HTTP\Parameters /v MaxConnections /t REG_DWORD /d 100000
5. 运行命令使用设置生效
net stop http & net start http & iisreset
完成上述4个设置,就可以支持10万个并发请求。
参考:
Modifying the ASP.NET Request Queue Limit | Microsoft Learn
让Windows Server 2008 + IIS 7+ ASP.NET 支持10万并发请求 - dudu - 博客园