Quantcast
Channel: Code Bucket
Viewing all articles
Browse latest Browse all 4

Apache Prefork MPM Configuration

0
0

If you have installed a new apache web server(prefork MPM), planning to launch an online application and exptecting good amount of traffic then before going live, check apache settings for prefork mpm otherwise your server will not able to serve even 20-30 users. Why, becouse apache default setting are not optimized for high traffic, you have to adjust prefork settings based on your application and hardware(RAM,Swap etc).

Before I will start explaining prefork configuration, if you are not aware of prefork mpm or how to check apache memory details then read following blogs before proceeding further:

Prefork Vs Worker
Apache Memory Details

Open your apache config file or run following command

gedit /etc/apache2/apache2.conf

Search prefork setting block, which look like this

<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>

Above is the default settings of apache prefork mpm.

StartServers: The StartServers directive sets the number of child server processes created on startup. As the number of processes is dynamically controlled depending on the load, there is usually little reason to adjust this parameter.

MaxSpareServers: The MaxSpareServers directive sets the desired maximum number of idle child server processes. An idle process is one which is not handling a request. If there are more than MaxSpareServers idle, then the parent process will kill off the excess processes.
Tuning of this parameter should only be necessary on very busy sites. Setting this parameter to a large number is almost always a bad idea. If you are trying to set the value lower than MinSpareServer.

MinSpareServers: The MinSpareServers directive sets the desired minimum number of idle child server processes. An idle process is one which is not handling a request. If there are fewer than MinSpareServers idle, then the parent process creates new children at a maximum rate of 1 per second.
Tuning of this parameter should only be necessary on very busy sites. Setting this parameter to a large number is almost always a bad idea.

MaxClients: The MaxClients directive sets the limit on the number of simultaneous requests that will be served. Any connection attempts over the MaxClients limit will normally be queued. Once a child process is freed at the end of a different request, the connection will then be serviced.
Generally number of MaxClients=(Total RAM memory – RAM memory used for other process except Apache process) / (Memory used by Single Apache process)

MaxRequestsPerChild: The MaxRequestsPerChild directive sets the limit on the number of requests that an individual child server process will handle. After MaxRequestsPerChildrequests, the child process will die. If MaxRequestsPerChild is 0, then the process will never expire.
You can keep it high (20000-25000) but never set it to 0.

Above mentioned setting are for start purpose only. To get best optimized setting you have to analyze sever performance on different load(for that you can use jmeter) and accordingly change the settings.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images