适用的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 32768 reg 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秒”问题的全新分析
8、修改tcp maxuserport限制
由默认5000改为65534,修改方法:在注册表 hklm\system\currentcontrolset\services\tcpip\parameters 中添加名为maxuserport,类型为dword(32-bit),值为65534(10进制)的项目并重启计算机。
发表评论