The optimal number of threads that Tomcat

What is the optimal number of threads?
To meet the needs of more users access, you can adjust the number of Tomcat threads, but not too large, otherwise causes the thread switching overhead, as the user increments (the number of threads can also be adjusted), increasing QPS system, when the user reaches a certain value amount , QPS does not increase, or increase is not obvious, but at the same time a substantial increase request response time. This threshold is considered to be the optimum number of threads.

How to calculate the optimal number of threads?
(1) pressure measured by the user slowly incrementing observed QPS, response time
(2) calculated by the formula: = the optimal number of threads ((thread thread cpu time latency +) / threads of cpu time) * cpu server Number

The maximum number of threads Windows:
32-bit system, by default, a thread's stack to reserve 1M memory space, and a process memory space is only available in 2G, so in theory a process can open up to 2048 threads

Linux maximum number of processes and the maximum number of threads, the test environment: 2-core 4G memory, 64-bit system,
the maximum number (pid_max) Process: 32768 (theoretical value)
maximum number of user processes (max user processes): 10240 (theoretical value)
maximum number of threads ( threads-max): 77132 (theoretical value)
the maximum number of users of threads: 1024 (theoretical)

Original Address: https://blog.csdn.net/liupeng_qwert/article/details/75110911

Guess you like

Origin www.cnblogs.com/jpfss/p/11015978.html