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

        在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));
    }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值