How to tune apache performance on Linux
The best performance to increase your Apache server with Websit, Monitoring tools, Redmine like that so on.
To add the bellow lines into your httpd.conf for apache configuration:
##
## Server-Pool Size Regulation (MPM specific)
##
# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
Note: First of all, whenever an apache is started, it will start 2 child processes which is determined by StartServers parameter. Then each process will start 25 threads determined by ThreadsPerChild parameter so this means 2 process can service only 50 concurrent connections/clients i.e. 25×2=50. Now if more concurrent users comes, then another child process will start, that can service another 25 users. But how many child processes can be started is controlled by ServerLimit parameter, this means that in the configuration above, I can have 16 child processes in total, with each child process can handle 25 thread, in total handling 16×25=400 concurrent users. But if number defined in MaxClients is less which is 200 here, then this means that after 8 child processes, no extra process will start since we have defined an upper cap of MaxClients. This also means that if I set MaxClients to 1000, after 16 child processes and 400 connections, no extra process will start and we cannot service more than 400 concurrent clients even if we have increase the MaxClient parameter. In this case, we need to also increase ServerLimit to 1000/25 i.e. MaxClients/ThreadsPerChild=40 So this is the optmized configuration to server 1000 clients
Timeout:-
The default value is 300. You should set time to something a bit lower. A setting of 150 is probably ok
# Timeout 150
StartServers:-
Sets the number of child server processes created on startup
# StartServers 5
MinSpareServers:-
Apache will fork new child-processes until MinSpareServers is satisfied.
Virtualized server, ie VPS 5
Dedicated server with 1-2GB RAM 10
Dedicated server with 2-4GB RAM 20
Dedicated server with 4+ GB RAM 25
# MinSpareServers 5
MaxSpareServers:-
MaxSpareServers directive sets the desired maximum number of idle child server processes. we should set the value as double the value of MinSpareServers. For example MinSpareServers 5 means SpareServers 10
# MaxSpareServers 10
ServerLimit:-
This value should be same as MaxClients
# ServerLimit 256
MaxClients:-
The maximum amount of requests that can be served simultaneously, with any number going past the limit being queued.
For virtualized servers such as VPS accounts, it is recommended to keep this value at 150. For all dedicated servers the recommended value for this setting is 256.
# MaxClients 256
MaxRequestsPerChild:-
This should not be set too low as it will put an unnecessary load on the apache server to recreate the child. Once the number of requests reaches the value specified, the child process will die. When this value is set at 0, then the process will never expire.
Virtualized server, ie VPS 500
Dedicated server with 1-4GB RAM 1000 to 4000
Dedicated server with 4+GB RAM set 0
# MaxRequestsPerChild 4000