Apache Performance Tuning
Apache is one of the most generally used web server applications, by default, however, it tends to consume quite some memory, although not necessarily a problem you might confront performance problems later on as your website or server produces more traffic/load.
In order to minimize the memory consumption and in the worst case avoid swapping then please consider following this article in order to increase the overall performance of your web server configuration.
Unload unwanted modules
Unfortunately, we can't decide for you what modules are a necessity so this should be something you should look after yourself depending on your demands, as some guidance, though, please consider the subsequent article if you're uncertain about what the purpose of a certain module is:
For Apache 2.2: http://httpd.apache.org/docs/2.2/mod/
For Apache 2.4: http://httpd.apache.org/docs/2.4/mod/
To list currently active modules on your VPS:
Modules are loaded using the LoadModule directive which is referenced by each module in
The ApacheBuddy script is inspired by MySQLTuner, this script makes some recommendations on your current Apache configuration and RAM usage and can be quite valuable as a starting point. The code can be retrieved from GitHub: https://github.com/gusmaskowitz/apachebuddy.pl
The script can be run through the following single command:
curl -L http://apachebuddy.pl/ | perl
Determine RAM usage
An alternative to ApacheBuddy can also be applied. The next tool gives you a comprehensive summary of the RAM usage per application and can be run by performing the following command:
curl -L https://raw.githubusercontent.com/pixelb/ps_mem/master/ps_mem.py | python
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, up to a number based on the ListenBacklog directive. Once a child process is freed at the end of a different request, the connection will then be serviced.
You can, and should, control the MaxClients setting so that your server does not spawn so many children it starts swapping. The procedure for doing this is simple: determine the size of your average Apache process, by looking at your process list via a tool such as top, and divide this into your total available memory, leaving some room for other processes.
The MaxClients directive should be set to a value based on the following formula:
MaxClients: ((Total_Memory)*(1024)(MB) - Other_processes_memory) / Apache_process_size = MaxClients
Note: You can use the ps_mem.py script discussed earlier to get the total RAM usage and divide it by a number of processes to get an average of the size that's used per Apache process.
There's a lot more that could be done to tune the performance of Apache. Most of it, however, is already described quite thoroughly and can be attained in the Official Apache Documentation.
You can find the documentation particularly about performance tuning here: http://httpd.apache.org/docs/current/misc/perf-tuning.html