打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
支持高并发的IIS Web服务器常用设置

适用的IIS版本:IIS 7.0, IIS 7.5, IIS 8.0

适用的Windows版本:Windows Server 2008, Windows Server 2008 R2, Windows Server 2012

1、应用程序池(Application Pool)的设置: 

  • General->Queue Length设置为65535(队列长度所支持的最大值)
  • Process Model->Idle Time-out设置为0(不让应用程序池因为没有请求而回收)
  • Recycling->Regular Time Interval设置为0(禁用应用程序池定期自动回收)

2、.Net Framework相关设置

a) 在machine.config中将

<processModel autoConfig="true" />

改为

<processModel enable="true" requestQueueLimit="100000"/>

(保存后该设置立即生效)

b) 打开C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\Browsers\Default.browser,找到<defaultBrowser id="Wml" parentID="Default" >,注释<capabilities>部分,然后运行在命令行中运行aspnet_regbrowsers -i。

<defaultBrowser id="Wml" parentID="Default" >    <identification>        <header name="Accept" match="text/vnd\.wap\.wml|text/hdml" />        <header name="Accept" nonMatch="application/xhtml\+xml; profile|application/vnd\.wap\.xhtml\+xml" />    </identification><!--    <capabilities>        <capability name="preferredRenderingMime"              value="text/vnd.wap.wml" />        <capability name="preferredRenderingType"              value="wml11" />    </capabilities>--></defaultBrowser>

以解决text/vnd.wap.wml问题。

3、IIS的applicationHost.config设置

设置命令:

c:\windows\system32\inetsrv\appcmd.exe set config /section:serverRuntime /appConcurrentRequestLimit:100000

设置结果:

<serverRuntime appConcurrentRequestLimit="100000" />

(保存后该设置立即生效)

4、http.sys的设置

注册表设置命令1(将最大连接数设置为10万):

reg add HKLM\System\CurrentControlSet\Services\HTTP\Parameters /v MaxConnections /t REG_DWORD /d 100000

注册表设置命令2(解决Bad Request - Request Too Long问题):

reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters /v MaxFieldLength /t REG_DWORD /d 32768reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters /v MaxRequestBytes /t REG_DWORD /d 32768

(需要在命令行运行 net stop http  & net start http & iisreset 使设置生效)

5、针对负载均衡场景的设置

在Url Rewrite Module中增加如下的规则:

<rewrite>    <allowedServerVariables>        <add name="REMOTE_ADDR" />    </allowedServerVariables>    <globalRules>        <rule name="HTTP_X_Forwarded_For-to-REMOTE_ADDR" enabled="true">            <match url=".*" />            <serverVariables>                <set name="REMOTE_ADDR" value="{HTTP_X_Forwarded_For}" />            </serverVariables>            <action type="None" />            <conditions>                <add input="{HTTP_X_Forwarded_For}" pattern="^$" negate="true" />            </conditions>        </rule>    </globalRules></rewrite>

相关博文:迁入阿里云后遇到的Request.UserHostAddress记录IP地址问题

注意事项:添加该URL重写规则会造成IIS内核模式缓存不工作,详见微软的坑:Url重写竟然会引起IIS内核模式缓存不工作

6、 设置Cache-Control为public

在web.config中添加如下配置: 

<configuration>    <system.webServer>        <staticContent>            <clientCache cacheControlCustom="public" />        </staticContent>    </system.webServer></configuration>

7、ASP.NET线程设置

在machine.config的<processModel>中添加如下设置: 

<processModel enable="true" maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50" minIoThreads="50"/>

相关博文:云计算之路-阿里云上:从ASP.NET线程角度对“黑色30秒”问题的全新分析

 

相关链接:

让Windows Server 2008 + IIS 7+ ASP.NET 支持10万并发请求

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
优化IIS7.5支持10万个同时请求的配置方法
ASP.NET 中的进程和请求标识
通过系统配置来提高ASP.NET应用程序的稳定性 @阿良.NET
让服务器能支持10万并发数秘诀,亲身经历,站在巨人的肩膀上创造
mantis安装与配置(Windows Mysql PHP IIS) - seventest - 51Testing软件测试网 - Powered by X-Space
windows server 2008下安装SQL SERVER 2005出现IIS功能要求警告解决方案
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服