配置 Microsoft Internet 信息服務 (IIS) Web 服務器上的 ASP.NET 進程模型設置。其做用是配置IIS或IIS中的應用程序池(IIS7及之後版本)的安全性,性能,健壯性,可靠性。 web
processModel 節只能在 Machine.config 文件中進行設置,它影響服務器上運行的全部 ASP.NET 應用程序。Machine.config文件則位於Windows\Microsoft.NET\Framework64\{.Net Framework Version}\Config或Windows\Microsoft.NET\Framework\{.Net Framework Version}\Config中。 安全
其配置節內容和默認設置以下,查看各個屬性的做用可參考https://msdn.microsoft.com/zh-cn/library/7w2sway1(VS.80).aspx 服務器
在IIS6中引入了應用程序池,在應用程序池的高級設置中就包含了processModel的設置,其中應用程序標識的配置和idleTimeout的設置在Machine.config和應用程序池高級設置中都存在,可是就以應用程序池的爲準了。 app
如在Machine.config中設置userName和password, ide
<processModel userName="Administrator" password="111" />
經過任務管理器查看進程的 性能
以及經過如下代碼查看進程的用戶名時均無生效 this
string GetProcessUserName(int pID) { string text1 = null; SelectQuery query1 = new SelectQuery("Select * from Win32_Process WHERE processID=" + pID); ManagementObjectSearcher searcher1 = new ManagementObjectSearcher(query1); try { foreach (ManagementObject disk in searcher1.Get()) { ManagementBaseObject inPar = null; ManagementBaseObject outPar = null; inPar = disk.GetMethodParameters("GetOwner"); outPar = disk.InvokeMethod("GetOwner", inPar, null); text1 = outPar["User"].ToString(); break; } } catch { text1 = "SYSTEM"; } return text1; }
可是在應用程序池的高級設置中設置則生效 spa
同理,設置閒置超時(idleTimeout)一樣都是在應用程序池中設置才生效,在Machine.config中設置超時時間爲1分鐘, .net
<processModel idleTimeout="1"/>
在應用程序池中設置爲2分鐘 線程
訪問站點後留意"任務管理器"中w3wp進程消失的時間,就會發如今靜置兩分鐘後w3wp被結束掉。
通過觀察還發現了其餘雖然不是重名的屬性,可是看其做用類似的,本人未去驗證其有效性,但也列舉出來
Machine.config ----------- 應用程序池
================================================
shutdownTime --------------- shutdownTImeLimit
pingInterval --------------- pingFrequency
pingResponseTime------------ pingTimeout
webGarden --------------- maxProcesses設置成大於1時
此外單純出如今Machine.config配置節的屬性仍是會生效的,例如經過查看應用程序池的線程數量來看對maxWorkerThreads和maxIoThreads是否會生效。
在Machine.config中添加如下設置。
<processModel autoConfig="false" maxWorkerThreads="1000" maxIoThreads="999" />
WebForm頁面的Page_Load方法添加如下代碼
int work,io; ThreadPool.GetMaxThreads(out work, out io); this.lb1.Text += string.Format("<br/> work {0} io {1}",work,io);
運行後發現執行結果以下
這裏額外說明一下,若是autoConfig設置成true,它會自動設置maxWorkerThreads和maxIoThreads,如需使用用戶自定義設置,則須要設置成false,另外maxWorkerThreads和maxIoThreads是單個CPU中工做線程與IO線程的數量,鄙人的電腦是雙核四線程,因此實際運行出來的結果是該設置值的4倍。
關於性能這一方面鄙人蔘考了微軟上面的一篇文章,閱讀以後總結了如下幾點
1.實際線程池的maxWorkerThreads和maxIoThreads是配置節中
maxWorkerThreads*CPU數
maxIoThreads*CPU數
2.minWorkerThreads最好設置成 minWorkerThreads = maxWorkerThreads / 2
3.單個CPU最多處理的請求數目爲 (maxWorkerThreads*number of CPUs)-minFreeThreads,minFreeThreads是httpRuntime配置節的Attribute
4.If you are making one Web service call to a single IP address from each ASPX page。Microsoft 建議您使用如下配置設置︰
•將maxWorkerThreads參數和maxIoThreads參數的值設置爲100。
•設置的maxconnection參數的值 12 *N (N是CPU數量)。
•設置的minFreeThreads參數的值 88 *N 和minLocalRequestFreeThreads參數76 *N.
•MinWorkerThreads爲50
例如,您有帶四個處理器和啓用超線程的服務器。根據這些公式,將本文中提到的配置設置使用下列值。
<system.web> <processModel maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50"/> <httpRuntime minFreeThreads="704" minLocalRequestFreeThreads="608"/> </system.web> <system.net> <connectionManagement> <add address="[ProvideIPHere]" maxconnection="96"/> </connectionManagement> </system.net>
參考文章
https://support.microsoft.com/zh-cn/kb/821268
https://msdn.microsoft.com/zh-cn/library/7w2sway1(VS.80).aspx
https://www.iis.net/configreference/system.applicationhost/applicationpools/add/processmodel