Apache prefork and worker working mode introduction

  
 

prefork mode Each process generates a child process to process the request worker mode. Each process generates multiple child processes, and each child process generates a thread processing request.


prefork works: control process After initially setting up the number of "StartServers", create a process to meet the needs of MinSpareServers settings, wait two seconds to create two, wait for one second to create four … up to 32 per second until satisfied MaxSpareServers sets the value so far, which is the origin of pre-pref (prefork), can generate new processes without having to request the arrival, thus reducing the system overhead

MaxSpareServers: set the maximum number of idle processes, If the number of idle processes is greater than this value, apache will automatically kill the redundant process. This value should not be set too large. If the value is smaller than the value of MinSpareServers, apache will automatically adjust to MinSpareServers+1

MaxRequestsPerChild : Set the number of requests that each child process can handle, 0 means unlimited


Worker works: Startup when starting "StartServ" Ers“ number of child processes, each child process contains the number of threads, and then the parent process detects the total number of idle threads in all child processes, and establishes or ends the child process so that idle threads are always maintained at " MinSpareThreads” And the range between &Maxquo; MaxSpareThreads”, this process is automatically adjusted, generally there is no need to modify the default value of these instructions


Official introduction to prefork and worker working mode

Apache MPM prefork process mode

Using multiple child processes, each child process has only one thread, each process maintains a connection at the same time, each request is independent of each other, does not affect other requests, to process Providing services, non-threaded

This multiprocessing module (MPM) implements a non-threaded, pre-derived web server that works like Apache 1.3. It is suitable for systems that do not have thread-safe libraries and need to avoid thread compatibility issues. It is the best MPM in the case of requiring each request to be independent of each other, so that if one request has a problem, it will not affect other requests. A separate control process (parent process) is responsible for generating the child processes. These child processes are used for Listening for requests and responding

Apache MPM worker Multi-threaded multi-process multiplex mode

Using multiple child processes, each child process has multiple threads, each thread maintaining one at a time Connection, using threads to process requests, can handle massive requests, so you can handle more concurrent requests (httpd at startup, there will be several child processes spawned by the root process, each child process will have a fixed number of threads, to These threads are provided when the service is provided, that is, one thread can provide multiple services at the same time.)

This multiplexing module (MPM) enables the network server to support mixed multi-threaded multi-process. Since threads are used to process requests, massive requests can be processed, while system resources are less expensive than process-based MPMs. However, it also uses multiple processes, each with multiple threads to get the stability of the process-based MPM

Copyright © Windows knowledge All Rights Reserved