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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章