《ASP.NET本质论》 ASP.NET 中线程池设置

来源:互联网 发布:淘宝女装店名起名大全 编辑:程序博客网 时间:2024/05/22 17:15

        在ASP.NET的服务处理中,每当服务器收到一个请求,HttpRuntiome将从HttpApplication池中获取一个HttpApplication对象处理此请求,请求的处理过程将被排入线程池中,对于ASP.NET来说,在 machine.config 文件的processModel部分 可以设置线程池的参数,常用哦参数设置如下:

参数

配置

autoConfig

基于服务器的配置自动设置以下配置参数:

1)maxWorkerThreads

2)maxIoThreads

3)httpRuntime元素的minFreeThreads属性

4)httpRuntime元素的minLocalRequestFreeThreads属性

5)connectionManagement元素的maxConnection属性

默认设置为True

maxWorkerThreads

设置每个CPU的最大工作线程数量,可以设置的范围为5100,默认为20,建议设置为100

minWorkerThreads

设置每个CPU的最少工作线程数量,默认为1

maxIoThreads

配置每个CPU的最大I/O线程数量,可以设置的范围为5100,默认为20,建议设置为100

minIoThreads

配置每个CPUT的最少I/O线程数量,默认为1





参数

配置

minFreeThreads

处理新请求保留的最少自由线程数量,默认值为8.建议每CPU设置为88

minLocalRequestFreeThreads

为本地主机请求保留的最少自由线程数量,默认值为4。建议每CPU设置为76

appRequestQueueLimit

在ASP.NET没有足够的线程来处理请求的时候,将会把这些请求排入一个请求队列中等待处理,appRequestQueueLimit用来设置这个队列的长度,当请求队列的长度超出这个参数的时候,服务器返回“503-Server Too Busy

默认为5000,在ASP.NET 1.1 中,默认为100



查看本机配置:

    protected void Page_Load(object sender, EventArgs e)    {        string path = this.Request.ApplicationPath;                Configuration config  = WebConfigurationManager.OpenWebConfiguration( null );        ProcessModelSection proecssModeSection  = config.GetSection("system.web/processModel")  as ProcessModelSection;        Response.Write( string.Format("MaxWorkerThreads: {0}", proecssModeSection.MaxWorkerThreads));        Response.Write(string.Format("MinWorkerThreads: {0}", proecssModeSection.MinWorkerThreads));        Response.Write( string.Format("MaxIOThreads: {0}", proecssModeSection.MaxIOThreads));        Response.Write( string.Format("MinIOThreads: {0}", proecssModeSection.MinIOThreads));        HttpRuntimeSection httpRuntimeSection   = config.GetSection("system.web/httpRuntime")  as HttpRuntimeSection;        Response.Write( string.Format("MinFreeThreads: {0}", httpRuntimeSection.MinFreeThreads));        Response.Write(string.Format("MinLocalRequestFreeThreads: {0}", httpRuntimeSection.MinLocalRequestFreeThreads));        Response.Write(string.Format("AppRequestQueueLimit: {0}", httpRuntimeSection.AppRequestQueueLimit));    }


原创粉丝点击