欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

優(yōu)化IIS7.5支持10萬個同時(shí)請求的配置方法

 更新時(shí)間:2013年04月26日 12:42:57   投稿:mdxy-dxy  
通過對IIS7的配置進(jìn)行優(yōu)化,調(diào)整IIS7應(yīng)用池的隊(duì)列長度,請求數(shù)限制,TCPIP連接數(shù)等方面,從而使WEB服務(wù)器的性能得以提升,保證WEB訪問的訪問流暢

通過對IIS7的配置進(jìn)行優(yōu)化,調(diào)整IIS7應(yīng)用池的隊(duì)列長度,請求數(shù)限制,TCPIP連接數(shù)等方面,從而使WEB服務(wù)器的性能得以提升,保證WEB訪問的訪問流暢。

IIS7.5是微軟推出的最新平臺IIS,性能也較以前有很大的提升,但是默認(rèn)的設(shè)置配不適合很大的請求。但是我們可以根據(jù)實(shí)際的需要進(jìn)行IIS調(diào)整,使其性能更佳,支持同時(shí)10萬個請求。

以下方案,通過對IIS7的配置進(jìn)行優(yōu)化,調(diào)整IIS7應(yīng)用池的隊(duì)列長度,請求數(shù)限制,TCPIP連接數(shù)等方面,從而使WEB服務(wù)器的性能得以提升,保證WEB訪問的訪問流暢。

今天下午17點(diǎn)左右,博客園博客站點(diǎn)出現(xiàn)這樣的錯誤信息:

Error Summary:

HTTP Error 503.2 - Service Unavailable
The serverRuntime@appConcurrentRequestLimit setting is being exceeded.

Detailed Error Information:

Module IIS Web Core
Notification BeginRequest
Handler StaticFile

Error Code 0x00000000

由于之前使用的是默認(rèn)配置,服務(wù)器最多只能處理5000個同時(shí)請求,今天下午由于某種情況造成同時(shí)請求超過5000,從而出現(xiàn)了上面的錯誤。

為了避免這樣的錯誤,我們根據(jù)相關(guān)文檔調(diào)整了設(shè)置,讓服務(wù)器從設(shè)置上支持10萬個并發(fā)請求。

具體設(shè)置如下:

1. 調(diào)整IIS 7應(yīng)用程序池隊(duì)列長度

由原來的默認(rèn)1000改為65535。

IIS Manager > ApplicationPools > Advanced Settings

Queue Length : 65535

2.  調(diào)整IIS 7的appConcurrentRequestLimit設(shè)置

由原來的默認(rèn)5000改為100000。

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

在%systemroot%\System32\inetsrv\config\applicationHost.config中可以查看到該設(shè)置:

<serverRuntime appConcurrentRequestLimit="100000" />


3. 調(diào)整machine.config中的processModel>requestQueueLimit的設(shè)置

1、單擊“開始”,然后單擊“運(yùn)行”。

2、在“運(yùn)行”對話框中,鍵入 notepad %systemroot%\Microsoft.Net\Framework64\v4.0.30319\CONFIG\machine.config,然后單擊“確定”。(不同的.NET版本路徑不一樣,你可以選擇你自己當(dāng)前想設(shè)置的.NET版本的config)

對于.net2.0對應(yīng)的是

notepad %systemroot%\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\machine.config

.4.0

notepad %systemroot%\Microsoft.Net\Framework64\v4.0.30319\CONFIG\machine.config

3、找到如下所示的 processModel 元素:<processModel autoConfig="true" />

4、將 processModel 元素替換為以下值:<processModel enable="true" requestQueueLimit="100000" />

5、保存并關(guān)閉 Machine.config 文件。
由原來的默認(rèn)5000改為100000。


<configuration>
    <system.web>
        <processModel enable="true" requestQueueLimit="100000"/>參考文章:http://technet.microsoft.com/en-us/library/dd425294(office.13).aspx

4. 修改注冊表,調(diào)整IIS 7支持的同時(shí)TCPIP連接數(shù)

由原來的默認(rèn)5000改為100000。

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

可在注冊表中查看

5. 運(yùn)行命令使用設(shè)置生效

net stop http  & net start  http & iisreset 完成上述4個設(shè)置,就可以支持10萬個并發(fā)請求,博客園博客服務(wù)器已經(jīng)啟用上述設(shè)置。

解決方案:

步驟一:調(diào)整IIS的應(yīng)用程序池隊(duì)列長度。
在【應(yīng)用程序池】列表中,選擇你相應(yīng)網(wǎng)站所使用的應(yīng)用程序池,將原來的隊(duì)列長度由1000改為65535。當(dāng)然這里的隊(duì)列長度你可以根據(jù)自己的訪問用戶*1.5來設(shè)置,例如:你有2000用戶,你此處就可以設(shè)置為3000(3000=2000用戶數(shù)*1.5), 官方參考

設(shè)置如下圖:

 步驟二:調(diào)整IIS的appConcurrentRequestLimit值

打開cmd命令,運(yùn)行命令:c:\Windows\System32\inetsrv\appcmd.exe set config /section:serverRuntime /appConcurrentRequestLimit:100000

 步驟三:修改ASP.NET請求隊(duì)列限制即調(diào)整machine.config中的processModel>RequestQueueLimit

1、單擊“開始”,然后單擊“運(yùn)行”。

2、在“運(yùn)行”對話框中,鍵入 notepad %systemroot%\Microsoft.Net\Framework64\v4.0.30319\CONFIG\machine.config,然后單擊“確定”。(不同的.NET版本路徑不一樣,你可以選擇你自己當(dāng)前想設(shè)置的.NET版本的config)

3、找到如下所示的 processModel 元素:<processModel autoConfig="true" />

4、將 processModel 元素替換為以下值:<processModel enable="true" requestQueueLimit="15000" />

 5、保存并關(guān)閉 Machine.config 文件。

步驟四:修改注冊表,調(diào)整IIS支持的并發(fā)TCPIP連接數(shù)

在cmd命令中運(yùn)行命令:reg add HKLM\System\CurrentControlSet\Services\HTTP\Parameters /v MaxConnections /t REG_DWORD /d 100000,當(dāng)然也可以手動去注冊表修改

為了方法大家與自己使用,我把上面能用bat操作簡單放到一個bat文件里面了。將下面的內(nèi)容保存為do.bat文件運(yùn)行就可以了,需要手工的自己操作

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

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

# 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

#更多的可以可以查看這篇文章,手工操作的可以查看這篇文章
start "C:\Program Files\Internet Explorer\iexplore.exe" http://www.dbjr.com.cn/article/36073.htm

下面為大家補(bǔ)充一點(diǎn)知識:

支持高并發(fā)的IIS Web服務(wù)器常用設(shè)置
適用的IIS版本:IIS 7.0, IIS 7.5, IIS 8.0

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

1、應(yīng)用程序池(Application Pool)的設(shè)置:

•General->Queue Length設(shè)置為65535(隊(duì)列長度所支持的最大值)
•Process Model->Idle Time-out設(shè)置為0(不讓應(yīng)用程序池因?yàn)闆]有請求而回收)
•Recycling->Regular Time Interval設(shè)置為0(禁用應(yīng)用程序池定期自動回收)

2、.Net Framework相關(guān)設(shè)置

a) 在machine.config中將


<processModel autoConfig="true" />

改為

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

(保存后該設(shè)置立即生效)

b) 打開C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\Browsers\Default.browser,找到<defaultBrowser id="Wml" parentID="Default" >,注釋<capabilities>部分,然后運(yùn)行在命令行中運(yùn)行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設(shè)置

設(shè)置命令:

c:\windows\system32\inetsrv\appcmd.exe set config /section:serverRuntime /appConcurrentRequestLimit:100000
設(shè)置結(jié)果:
<serverRuntime appConcurrentRequestLimit="100000" />

(保存后該設(shè)置立即生效)

4、http.sys的設(shè)置

注冊表設(shè)置命令1(將最大連接數(shù)設(shè)置為10萬):


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

注冊表設(shè)置命令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

(需要在命令行運(yùn)行 net stop http  & net start http & iisreset 使設(shè)置生效)

5、針對負(fù)載均衡場景的設(shè)置

在Url Rewrite Module中增加如下的規(guī)則:

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

相關(guān)博文:遷入阿里云后遇到的Request.UserHostAddress記錄IP地址問題

注意事項(xiàng):添加該URL重寫規(guī)則會造成IIS內(nèi)核模式緩存不工作,詳見微軟的坑:Url重寫竟然會引起IIS內(nèi)核模式緩存不工作。

6、 設(shè)置Cache-Control為public

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

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


7、ASP.NET線程設(shè)置

在machine.config的<processModel>中添加如下設(shè)置:


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

相關(guān)文章

最新評論