ASP.NET線程相關配置

1ASP.NET 同一時刻只能發起的工作線程數量:

(maxWorkerThreads * CPU邏輯數量)-minFreeThreads

比如2CPU默認配置maxWorkerThreads=100minFreeThreads=176,則同時最大只能有24個工作線程。(這里不管 ?<system.net>

??? <connectionManagement>

????? <add address="*" maxconnection="8" />

??? </connectionManagement>

?</system.net>這個配置的值,經過測試,不管這里的maxconnection為多少,最終都是從上面的計算公式計算出來的)

?

2maxconnection,這個值是每秒可以支持的線程數。(但實際每秒可以并行運行的線程為(maxWorkerThreads * CPU邏輯數量)-minFreeThreads的結果),一般要求支持并發量,每個并發請求都很耗時的情況下,就需要設置該值為對應的并發量(有這么多線程來處理),但線程多了切換也很耗服務器資源,實際情況往往不一定請求都很耗時,所以根據實際情況調整。

?

3maxWorkerThreads是最大工作線程,默認100我覺得再非高并發下還是可以

?

4minWorkerThreads是最小工作線程,由于托管線程啟動比較耗時,根據實驗結果:40秒啟動了18個線程,大概接近官方說的每秒接近2個。由于線程開銷比較耗時,因此可以初始化到正常情況下的最低支持并發數量。比如我們平臺白天最少有10個并發,則可以設置最小線程為52CPU),或者服務端可能會遇到瞬間的超大并發量的請求,則可設置默認最小工作線程更大一點,可以快速處理請求。minWorkerThreads只對遞增線程有影響,不影響穩定后的并發量。

?

5、最小空閑線程minFreeThreads參數的配置,有的官方資料建議配置成88*N的數量(如果maxWorkerThreads100的情況),因為說為了留足夠的空閑線程給系統用,但是經過測試,發現高壓下,缺空閑線程真的空閑起來了,根本沒有用,因此我覺得應該把這個值設置小一點,比如設置為80maxWorkerThreads100的情況),就會留下100*2-80=120個最大連接,在高壓下就能建立120個線程,速度和效率會很快。

?http://lawson.cnblogs.com/

?

注意點:

1CPU邏輯數量:按照物理CPU數量,如果CPU是超線程(多核)會再乘以2

2同一時間可處理量不代表每秒可處理量,比如同一時間可以處理20個,可能每秒能處理200個,因為每個請求只要0.1秒。

3、注意配置節點中processModel里的maxWorkerThreadsmaxIoThreadsminWorkerThreadsminIoThreads都只配置單CPU邏輯數量的值,計算時會自動乘以CPU邏輯數量。

4、配置節點包括:

System.web節點下:

??? <processModel autoConfig="false"

??? maxWorkerThreads = "100"

??? maxIoThreads = "100"

??? minWorkerThreads = "20"

??? minIoThreads = "20"

/>

??? <httpRuntime

?minFreeThreads="100"

?minLocalRequestFreeThreads="100"

/>

System.web同級節點下

?<system.net>

??? <connectionManagement>

????? <add address="*" maxconnection="8" />

??? </connectionManagement>

?</system.net>

5、利用到的獲取參數代碼:

??????????? string result = string.Empty;

??????????? int maxWorkThread = 0;

??????????? int maxIOThread = 0;

??????????? int minWorkThread = 0;

??????????? int minIOThread = 0;

??????????? int workThread = 0;

??????????? int completeThread = 0;

??????????? ThreadPool.GetMaxThreads(out maxWorkThread, out maxIOThread);

??????????? ThreadPool.GetMinThreads(out minWorkThread, out minIOThread);

??????????? ThreadPool.GetAvailableThreads(out workThread, out completeThread);

?

??????????? result = DateTime.Now.ToString() + ":" + "\r\n";

??????????? result += "最大工作線程:" + maxWorkThread + ",最大IO線程:" + maxIOThread + "\r\n";

??????????? result += "最小工作線程:" + minWorkThread + ",最小IO線程:" + minIOThread + "\r\n";

??????????? result += "可用工作線程:" + workThread + ",可用IO線程:" + completeThread + "\r\n";

??????????? result += "\r\n";

(把result記錄下來,沒有用StringBuilder,臨時用的)

以上根據自己實驗得出的結論,如轉載,請注明來自:http://lawson.cnblogs.com/

?

可能存在實驗數據和結果方面的問題,如有發現,請指正?

轉載于:https://www.cnblogs.com/Lawson/archive/2012/07/08/2581443.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377370.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377370.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377370.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Android 編程下 AlarmManager

對應 AlarmManager 有一個 AlarmManagerServie 服務程序&#xff0c;該服務程序才是正真提供鬧鈴服務的&#xff0c;它主要維護應用程序注冊的各類鬧鈴并適時的設置即將觸發的鬧鈴給鬧鈴設備 ( 在系統中&#xff0c;Linux 實現的設備名為 ”/dev/alarm” ) &#xff0c;并且一直…

erp開發模式_ERP的完整形式是什么?

erp開發模式ERP&#xff1a;企業資源計劃 (ERP: Enterprise Resource Planning) ERP is an abbreviation of Enterprise Resource Planning. It is incorporated business management that is executed by a lot of numerous business houses to enhance their productivity an…

關于placement new 和 placement delete的重載,以及basic_string重載new()實例

關于placement new 在https://blog.csdn.net/qq_42604176/article/details/111997397中已經介紹了placement new的形式。 它的形式為new()/delete().我們將分配好內存的指針送入括號中&#xff0c;就完成了初步的調用了。 其實我們可以定義放任何的東西到()內部。只放一個指針…

cwc云萊特鏈_CWC的完整形式是什么?

cwc云萊特鏈CWC&#xff1a;工作條件的改變 (CWC: Change in Working Conditions) CWC is an abbreviation of "Change in Working Conditions". CWC是“工作條件更改”的縮寫 。 It is an expression, which is commonly used in the Gmail platform. In a particu…

在eclipse中創建web項目(非myeclipse)

在eclipse中創建web項目(非myeclipse) 在eclipse中如何創建dynamic web project項目 本文的演示是從本地文件創建dynamic web project&#xff0c;從svn檢出的同時創建dynamic web project于此類似。我們推薦使用解壓版的tomcat6.x版本&#xff0c;來作為服務器。可以到http://…

opengl glut 編譯

新建工程glut dll工程&#xff0c;本來想創建lib,工程的&#xff0c;但是想起來&#xff0c;gl是狀態機機制。dll方便資源共享等。 添加兩個include目錄 各種手機電腦平臺&#xff0c;網絡多媒體開發,mmsplayer&#xff0c;QQ514540005 然后將目錄下的lib/glut下面所有的.c文件…

劃分數據集代碼(按照4:1的比例)以及根據各自文件名寫入txt文件

會將圖片分到兩個文件夾中&#xff1a; #include <opencv2/opencv.hpp> #include "opencv2/features2d.hpp" #include <vector> #include <algorithm> #include <iostream> #include "windows.h" #include <stdio.h> #incl…

bpo是什么意思_BPO的完整形式是什么?

bpo是什么意思BPO&#xff1a;業務流程外包 (BPO: Business Process Outsourcing) BPO is an abbreviation of Business process outsourcing. It is a convention of a company to another company which is an external provider of services or business operations process…

在進行 ASP.NET 開發時,有時候需要對頁面輸出的最終 HTML 源代碼進行控制

在進行 ASP.NET 開發時&#xff0c;有時候需要對頁面輸出的最終 HTML 源代碼進行控制&#xff0c;是頁面的 render 方法中很容易實現這個功能。下面就是一個實現的方法&#xff0c;注釋都在代碼中。 [c-sharp] view plaincopy <% Page Language"C#" %> <% …

FireFox插件SQLite Manager的使用

最近幾天開始高IOS數據庫來著&#xff0c;一開始就CoreData的學習&#xff0c;結果高了一天沒有一點進展。 沒法&#xff0c;還是先老實代碼著吧&#xff0c;不過用的火狐插件可視化數據庫的操作也是不錯的似乎。 網上搜了搜用法&#xff0c;還真沒找到有什么的&#xff0c;最后…

簡單的數據增強代碼(C++與opencv)

包括了圖片批量平移、旋轉、以及像素變換 #include <opencv2/opencv.hpp> #include "opencv2/features2d.hpp" #include <vector> #include <algorithm> #include <iostream> #include "windows.h" #include <stdio.h> #in…

aes模式_AES的完整形式是什么?

aes模式AES&#xff1a;高級加密標準 (AES: Advanced Encryption Standard) AES is an abbreviation of Advanced Encryption Standard, also known by its original name Rijndael. It is an arrangement of standard for the encryption of electronic data set up by the U.…

IOS ----UIButton用法詳解

這段代碼動態的創建了一個UIButton,并且把相關常用的屬性都列舉了.希望對大家有用. //這里創建一個圓角矩形的按鈕UIButton *button1 [UIButton buttonWithType:UIButtonTypeRoundedRect];// 能夠定義的button類型有以下6種&#xff0c;// typedef enum {// UIButtonTypeCusto…

針對一個class寫出它的內存管理池以及總結出allocator類(三個版本)

目錄示例版本1&#xff1a;per-class allocator,1示例版本2&#xff1a;per-class allocator,2最終版本&#xff1a;static allocator針對版本三進行macro如果我們不針對對象做內存管理&#xff0c;那么我們每次進行Foo* p new Foo(x);時總是會調用malloc函數。 盡管malloc函數…

kotlin 第一個程序_Kotlin程序添加兩個矩陣

kotlin 第一個程序Given two matrices, we have to add them. 給定兩個矩陣&#xff0c;我們必須將它們相加。 Example: 例&#xff1a; Input:matrix 1:[2, 3][4, 5][7, 1]matrix 2:[4, 6][9, 0][7, 6]Output:[6, 9][13, 5][14, 7] 在Kotlin中添加兩個矩陣的程序 (Progra…

ubuntu 切換用戶的命令[shell, linux]

使用ubuntu過程中免不了和shell(終端)打交道, 也不可避免在各種用戶之間進行切換, 從而實現對各帳戶的管理, 這個就涉及到了一個比較基礎又很重要的工作,怎么樣切換用戶, 對于LINUX老鳥來說,這個根本不值不提的東東卻讓新手撓頭不已, 現在給出普通用戶和超級用戶切換的命令(附圖…

曲苑雜壇--修改數據庫名和文件組名

/* 該腳本示例如何完整的修改一個數據庫的名稱. 數據庫為原名稱為DB_BEIJING&#xff0c;需要修改成DB_SHANGHAI nzperfect 2012.12.19 */--判斷是否存在同名的數據庫&#xff0c;以防止誤刪除 USE master GO IF EXISTS (SELECT name FROM sys.databases WHERE name NDB_BEIJI…

關于new handler與default、delete關鍵字

在https://blog.csdn.net/qq_42604176/article/details/111638568的operate_new源代碼長啥樣中談到過new handler。 當operator new不能夠分配出申請的內存時&#xff0c;會拋出bad_alloc 異常。有的編譯器會返回0. 當定義成new(nothrow) Foo&#xff1b;就不會拋異常&#xff…

模式匹配運算符–Shell

轉載&#xff1a;http://www.firefoxbug.net/?p722 Var/home/firefox/MyProgram/fire.login.name ${Variable#pattern}:如果模式匹配于變量值的開頭處&#xff0c;則刪除匹配的最短部分&#xff0c;并且返回剩下的部分 例子&#xff1a; [fire]$ echo ${Var#*/} [fire]$ home/…

河內塔問題_河內塔的Python程序

河內塔問題You are challenged for a challenge to find the number of moves required to move a stack of disks from one peg to another peg. Wait for a second, it sounds easy? Let’s find are what is going on and in this article, we are introducing a chapter o…