1. (maxWorkerThreads * CPU logic number)-minFreeThreads
For example, if the default configuration of 2 CPUs is maxWorkerThreads=100 and minFreeThreads=176, then there can only be 24 worker threads at the same time. (Not care here <>
<connectionManagement>
<add address="*" maxconnection="8" />
</connectionManagement>
</>The value of this configuration has been tested. No matter how much maxconnection is, it is finally calculated from the above calculation formula)
2. maxconnection, this value is the number of threads that can be supported per second. (But the actual threads that can run in parallel per second are (maxWorkerThreads * CPU logic number) - the result of minFreeThreads). Generally, it is required to support concurrency. When each concurrent request is time-consuming, it is necessary to set this value to the corresponding concurrency (there are so many threads to handle). However, switching with more threads is also very consuming server resources. In actual situations, the requests are often not necessarily time-consuming, so adjust according to the actual situation.
3. maxWorkerThreads is the largest worker thread, and the default is 100. I think it is still OK to use it in concurrently.
4. minWorkerThreads is the smallest worker thread. Since the hosting thread is time-consuming to start, according to the experimental results: 18 threads were started in 40 seconds, which is about 2 times per second as the official said. Because thread overhead is time-consuming, it can be initialized to the minimum number of supported concurrency under normal circumstances. For example, if our platform has at least 10 concurrencies during the day, we can set the minimum thread to 5 (2 CPUs), or the server may encounter a request with a very large concurrency in an instant, so we can set the default minimum worker thread to be larger and can quickly process the request. minWorkerThreads only affects incremental threads and does not affect the amount of concurrency after stability.
5. The configuration of the minimum idle thread minFreeThreads parameter. Some official information recommends that the number of 88*N is configured (if maxWorkerThreads is 100), because in order to leave enough idle threads for the system to use, but after testing, it was found that under high voltage, the missing idle threads are really idle, which is useless at all. Therefore, I think this value should be set smaller, such as setting it to 80 (maxWorkerThreads is 100), 100*2-80=120 maximum connections will be left, and 120 threads can be established under high voltage, and the speed and efficiency will be very fast.
Note:
1. Number of CPU logic: According to the number of physical CPUs, if the CPU is hyperthreaded (multi-core), it will be multiplied by 2.
2. The amount that can be processed at the same time does not represent the amount that can be processed per second. For example, 20 can be processed at the same time, and 200 can be processed per second, because each request only takes 0.1 second.
3. Pay attention to the maxWorkerThreads, maxIoThreads, minWorkerThreads, and minIoThreads in the processModel in the configuration node only configure the values of the single CPU logic number, and will be automatically multiplied by the CPU logic number during calculation.
4. The configuration node includes:
Under node:
<processModel autoConfig="false"
maxWorkerThreads = "100"
maxIoThreads = "100"
minWorkerThreads = "20"
minIoThreads = "20"
/>
<httpRuntime
minFreeThreads="100"
minLocalRequestFreeThreads="100"
/>
Under the same level node
<>
<connectionManagement>
<add address="*" maxconnection="8" />
</connectionManagement>
</>
5. Used to obtain parameter code:
string result = ;
int maxWorkThread = 0;
int maxIOThread = 0;
int minWorkThread = 0;
int minIOThread = 0;
int workThread = 0;
int completeThread = 0;
(out maxWorkThread, out maxIOThread);
(out minWorkThread, out minIOThread);
(out workThread, out completeThread);
result = () + ":" + "\r\n";
result += "Maximum worker thread: " + maxWorkThread + ", maximum IO thread: " + maxIOThread + "\r\n";
result += "Minimum worker thread: " + minWorkThread + ", minimum IO thread: " + minIOThread + "\r\n";
result += "Available worker thread: " + workThread + ", available IO thread: " + completeThread + "\r\n";
result += "\r\n";
(Record result, use StringBuilder without using, temporarily)
Reprinted:/