Tuning Your Apache Server

Anil

Administrator
Staff member
Aug 14, 2021
440
14
18
Hyderabad
Centos: httpd.conf
Debian,Ubuntu : apache2.conf


Prefork

The prefork module creates a number of child processes at launch, each child handles only one thread. Since these processes deal solely with one thread at a time, request speed can suffer should there be too many concurrent requests. When this occurs, some requests essentially have to wait in line to be acted upon. To handle this, you can increase the number of child processes that are spawned, however, this increases the amount of RAM being used. Prefork is the safest module, and should be used when using non-thread-safe libraries.



Worker
The worker module’s child processes spawn many threads per process with each thread ready to take on new requests. This allows for a greater number of concurrent requests to come in, and in turn, is easier on the server’s RAM usage. Overall, the worker module offers higher performance, but is less secure than the prefork module and cannot be used with modules that are not thread safe.



Event
The event module is only available on Apache 2.4 and is based off of the worker MPM. Like the worker, it creates multiple threads per child process, with a thread dedicated to KeepAlive connections that are handed down to child threads once the request has been made. This is good for multiple concurrent connections, especially those that are not all active at the same time but make the occasional request. The event MPM functions the same as worker in the event of SSL connections.



Change Settings to Match

Code:
KeepAlive Off

KeepAliveTimeout 1

MaxKeepAliveRequests 1


Add & Tweak as needed:


Code:
<IfModule worker.c>

StartServers 100

MinSpareServers 2

MaxSpareServers 1

MaxClients 1

ThreadsPerChild 1

MaxRequestsPerChild 2

</IfModule>




<IfModule mpm_prefork_module>

StartServers 1

MinSpareServers 2

MaxSpareServers 1

MaxClients 100000

MaxRequestsPerChild 2

</IfModule>