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