Advantages and disadvantages of prefork, worker, and event in httpd working mode:
Http service requires a connection between the client and the server. httpd has three working modes: prefork worker event
Advantage: stable services when resources are sufficient
Worker: this is to improve the previous Working Model and let a process multiple responses.
Event: This model allows a process to generate multiple threads, so that each thread can process client requests, and each thread can process multiple threads.
Run the httpd-l command to view the currently loaded MPM module.
[Root @ s ~] # Httpd-l
Compiled in modules:
Core. c
Prefork. c
Http_core.c
Mod_so.c
Differences between http 2.2 and 2.4
Httpd2.2 you can modify the configuration file to change the modules used by the current server.
Http2.4: static module dynamic module
If MPM is compiled into a static module, you must modify the MPM by re-Compiling and installing httpd.
[Root @ s yum. repos. d] # ps uax | grep httpd
Root 2918 0.0 0.3 119088 1616 pts/2 S + vi httpd
Root 2997 0.0 0.5 183720 2720? Ss/usr/sbin/httpd
Root 3001 0.0 0.1 103252 824 pts/1 S + grep httpd
Remove comments from the/etc/sysconfig/httpd line.
HTTPD =/usr/sbin/httpd. worker
[Root @ s yum. repos. d] # ps aux | grep http
Root 2918 0.0 0.3 119088 1616 pts/2 S + vi httpd
Root 3029 0.0 0.8 186560 4164? Ss/usr/sbin/httpd. worker
Apache 3034 0.0 0.6 596356 3340? Sl/usr/sbin/httpd. worker
Apache 3035 0.1 0.6 596356 3336? Sl/usr/sbin/httpd. worker
Apache 3036 0.1 0.6 596356 3340? Sl/usr/sbin/httpd. worker
Root 3150 0.0 0.1 103252 828 pts/1 S + grep http
<IfModule prefork. c> If the prefork. c Module exists, the parameter defined in the label is valid.
StartServers 8: Number of worker processes enabled by default, excluding the master Process
MinSpareServers 5: Minimum number of idle Processes;
MaxSpareServers 20 Max number of idle processes;
ServerLimit 256 maximum number of active processes;
MaxClients 256 maximum number of concurrent requests, maximum number of requests processed by a process
MaxRequestsPerChild 4000 maximum number of requests that each sub-process can provide during its lifecycle
</IfModule>
<IfModule worker. c>
The number of sub-processes started when the StartServers 4 service is enabled;
MaxClients 300 maximum number of concurrent requests;
MinSpareThreads 25 min Number of Idle threads;
MaxSpareThreads 75 max Number of idle processes;
ThreadsPerChild 25: The number of threads in each sub-process;
MaxRequestsPerChild 0: Maximum number of requests that each sub-process can provide during the lifecycle. 0 indicates that the number of requests is not limited.
</IfModule>
Event parameter in httpd 2.4
<IfModule mpm_event_module>
Default StartServices process count
MinSpareThreads minimum number of idle Processes
MaxSpareThreads maximum number of idle Processes
ThreadsPerChild: the number of threads that each sub-process can generate.
MaxReqestWorkers maximum number of threads
The maximum number of connections of MaxConnectionPerchild sub-processes. When the set value is reached, APACHE ends the current sub-process.
Conclusion: parameters must be set for security and efficiency, and can be tested on your own to achieve satisfactory configuration.
CentOS 6.5 compile and install httpd-2.4.7