Apache working mode NPM Multi-processing module

Apache three working modes

prefork

MPM

work

insert image description here
insert image description here

event

The monitoring thread is equivalent to the project team leader, facing customers, and dispatching team members according to tasks.
insert image description here
insert image description here

Prefork mode is the working mode used by Apache by default. In this mode, the mechanism adopted is to pre-fork child processes and use separate processes to handle different requests. If Apache is running in Prefork mode, the Apache control process will create processes according to the value of MinSpareServers in the configuration file
after the initial startup . After the initial StartServer process starts, wait one second, the first process is created, wait two seconds, two more processes are created, after another second, 4 more processes are created, always exponentially Increase, up to 32 processes are created per second, until the value of MinSpareServers is met. The advantage of Prework is that it does not need to create a new process after receiving a client request , thus reducing the system overhead to a certain extent, but the process consumes a certain amount of system resources relatively speaking.

3. The Worker working mode is
different from the Prefork mode. The Worker mode uses different threads to process different client requests. After the control process is started, it regrets to start the corresponding number of threads under the process according to the value of ThreadsPerChild in the configuration file. These threads process client requests concurrently. If there are too many client requests and the number of threads in one process cannot handle them, other processes will be created in Worker mode, and different threads will continue to be created in the new process, and all threads will process client requests concurrently. . Therefore, in Worker mode, the number of concurrency processed at the same time is the number of processes × the number of threads under each process, but the number of processes cannot exceed the ServerLimit value in the configuration file.
Compared with the Prefork working mode, the Worker working mode uses threads to process client requests, occupies less memory, and is suitable for web server deployment in high-concurrency scenarios. However, the disadvantage of threads relative to processes is that the stability is relatively poor. In Prefork mode, when a process crashes, only the process itself is affected, but in Worker mode, when a thread crashes, the process will All threads of will be affected.

Guess you like

Origin blog.csdn.net/u013400314/article/details/131736669