There could be many reasons why your Apache web server is slow. One of them can be that Apache needs tuning. Tuning the Apache performance using the Apache MPM prefork module is one of them.
StartServers: 30% of MaxClients
MinSpareServers: 5% of MaxClients
MaxSpareServers: 10% of MaxClients
MaxRequestWorkers = MaxClients
MaxConnectionsPerChild= 10000 (To avoid problem with memory leaks in WordPress plugin themes and apps)
Edit the file with this command:
sudo nano /etc/apache2/mods-available/mpm_prefork.conf
Try these values if Apache uses 70 MB under heavy load and the server has 1 GB RAM.
<IfModule mpm_prefork_module> StartServers 8 MinSpareServers 8 MaxSpareServers 9 MaxRequestWorkers 9 MaxConnectionsPerChild 100 </IfModule>
Save the changes
Ctrl+X - Y
sudo service apache2 restart
It might make the server a bit slower, but there will be the most available memory, and you will not hit the roof. Hitting the limit will almost stop the server.
The initial Ubuntu OS install uses 350 MB RAM – memory – and the server has 1 GB with memory.
Then there is half a gigabyte to run Apache clients.
You measure that each Apache instance uses 33 MB of memory. Then you would be able to run 18 servers with 650 MB available RAM. 650 MB RAM allows ten customers to download content from your site simultaneously. Often the browser uses several simultaneous instances so one user could use several Apache instances. Upgrade to 4 GB of RAM then you would have 3.5 GB available to serve your customers with Apache. 3,5 GB of available memory would suggest a “MaxClients” settings increased from ten clients to 106.
This Perl script compares the size of running Apache HTTP processes. This consist of the configured Prefork, worker and event MPM limits. Measured towards the server’s available memory. You might get an error message if the setting limits exceed the server’s available memory.
Check the website for the newest release.
Go to the user home folder
Create a folder
Go to the newly created folder
Download the latest version. This is for version 2.5:
Unzip the file
Make the script executable:
chmod u+x check_httpd_limits.pl
Run the script as root
Open a bunch of web pages while you run the script many times to get an impression of the average memory consumed.
Please read this tutorial about oApache” performance using optimizing MPM Prefork module
Create a folder and download and unzip the script as you did with “Tool 1”
Make the script executable
chmod u+x ap.sh
Run the script