Detailed calculation and reasoning process of the thread carrying capacity of the server

JVM memory
Stack: stack space. Used to execute code blocks. Each thread has an exclusive Stack
Heap: heap space. Used to store objects. All threads share a Heap
Method Area: method area. In JDK1.8, there is no method area in the JVM provided by Hotspot, instead it is the permanent generation and meta space in the heap memory. Used for class information/used to store bytecode objects of the class. All threads share a Method Area
Native Stack: local method stack. Used to execute native methods-methods that are modified by native and completed in other languages ​​are called native methods. Each thread has an exclusive Native Stack
Program Counter: program counter. Count the instructions. Each thread has an exclusive Program Counter

The thread carrying capacity of a server is determined by the CPU and memory. The memory has a greater impact.
Consider: stack memory, local method stack, and PC counter can even affect the number of threads. The
PC counter is very small, only a few bytes in size. Ignored
The size of the local method stack is determined by the logic and language of the executed method. The
stack memory is specified in JDK1.8 and cannot be less than 128KB

Consider the extreme case: Ignore counter PC and native method stacks, according to stack memory to a minimum count, in this case, a server capable of carrying a number of threads
in the JVM stack memory specified physical memory can not exceed 2/3
assume a The memory of a server is 128G, so the actual memory used is about 115G
115G*2/3/128K≈628053

Can the local method stack be ignored during actual execution? - not
the number counted out so this time will need to be at least halved
628053--> 314 026
If you perform complex logic, memory is not in accordance with the smallest stack to count, then this will have to reduce the number of

Guess you like

Origin blog.csdn.net/qq_41536934/article/details/113985125