July 20th, 2011
If you find that even with smaller amounts of traffic that your server is regularly over-using resources (such as RAM and CPU) and not performing efficiently, you may need to make a few adjustments to Apache.
For one, in a VPS or limited-resource environment, it’s best to use the Apache Prefork MPM with Apache 2.2. You can enable this in EasyApache under the Apache Modules step. When using Prefork, new processes are created for each request and spare processes stay idle on the server, reducing overhead from startup. Each process handles a certain amount of requests before being killed, significantly eliminating the risk of memory leaks.
After Apache 2.2 and MPM Prefork are enabled, you can go into WHM > Apache Configuration > Global Configuration and adjust the settings for StartServers, MinSpareServers, MaxSpareServers,ServerLimit, MaxClients, and MaxRequestsPerChild. This will take some trial and error as well as light reading in the Apache documentation. For a “normal” VPS environment with 512MB of RAM and handful of sites with moderate traffic, you may want to start with the following settings:
<IfModule prefork.c>
StartServers 20
MinSpareServers 20
MaxSpareServers 50
ServerLimit 500
MaxClients 500
MaxRequestsPerChild 4000
</IfModule>
Now, set your TimeOut value a little bit lower, to about 150 (default is 300). This will help prevent requests from tying up processes while waiting for certain events. The KeepAliveTimeout should also be set to 2-3 seconds for the same reason.
When you’re done, Save your settings and Restart Apache on the next page.
Do keep in mind that even with the best optimization settings, there are times where a server’s traffic is just too much for its resources. If you are experiencing constant performance issues even after adjusting your Apache settings, you may want to consider making changes to your websites to reduce their resource usage, or consider adding more RAM or CPU power to your server environment.
Posted in Articles | No Comments
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment