Optimize the Apache Configuration
Apache is the service, which makes your website available online for the world to see. So, while modifying the Apache’s configuration is not advisable at all if you don’t know what you are doing, you can still enhance its performance with a few simple tweaks. Apache Optimization ======================= Apache can be a big memory user. Apache runs a number of ‘servers’ and shares incoming requests among them. The memory used by each server grows, especially when the web page being returned by that server includes PHP or Perl that needs to load in new libraries. It is common for each server process to use as much as 10% of the server’s memory. To reduce the number of the servers, you can edit your httpd.conf file. There are three settings to tweak: StartServers, MinSpareServers, and MaxSpareServers. Each can be reduced to a value of 1 or 2 and your server will still respond promptly, even on the quite busy sites. Here, the ‘prefork’ values are the ones that must be changed. All Apache settings are stored in the httpd.conf file, which is located at /etc/httpd/conf/httpd.conf/ The optimal Apache configuration should look like this: 1. KeepAlive On 2. MaxKeepAliveRequests 100 3. KeepAliveTimeout 1 4. MinSpareServers 5 5. MaxSpareServers 10 6. StartServers 5 7. MaxClients 150 8. MaxRequestsPerChild 1000 Restarting MySQL & Apache ============================== Once you have performed the required operations, you will have to restart the Apache service.You can do this via the command line or via the WHM. Restart Apache: /etc/init.d/httpd restart Under WHM, type “restart” in the search box and you will be presented with highlighted results from all the sentences that contain that word. Restart the relevant services. Monitoring Changes ======================= Use the ‘top’ command, ‘free – m’ & ‘ps aux’, to check the running processes and the current server load. If you see a spike in the Memory or the CPU usage, try to revise the Apache settings and assign them lower values. Originally published Wednesday, March 3rd, 2010 at 8:50 am, updated March 4, 2010 and is filed under Dedicated Hosting Services.