I noticed that after 8 months of running my VPS without a reboot my website was a big sluggish. I quickly checked my load average (w or uptime), virtual memory usage (vmstat -S m), and then I drilled in to usage with top. Apache and MySQL were the top offenders. I quickly made some tweaks and resolved the issue:
If you use the
--skip-bdb option, MySQL does not initialize the Berkeley DB library and this saves a lot of memory. However, if you use this option, you cannot use
BDB tables. If you try to create a
BDB table, MySQL uses the default storage engine instead.
Disable the BDB storage engine. This saves memory and might speed up some operations. Do not use this option if you require BDB tables.
The Apache tweaks were pretty standard as well. MaxClients, Timeout, KeepAlive, MaxKeepAlive, and KeepAliveTimeout. The biggest issue was MaxClients due to limited memory resources within this VPS. They have some great documentation here:
The single biggest hardware issue affecting webserver performance is RAM. A webserver should never ever have to swap, as swapping increases the latency of each request beyond a point that users consider “fast enough”. This causes users to hit stop and reload, further increasing the load. You can, and should, control the MaxClients setting so that your server does not spawn so many children it starts swapping. This 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.
Normally in the past I’ve always had to troubleshoot in the opposite direction. For example a customer with hundreds of thousands of hits a day will have a message board that couldn’t keep up with > 1,000 users at once. In that case the same type of tweaks were necessary, but in the opposite direction. We also had a lot of luck with solutions like eAccelerator for PHP caching and mySQL configuration tweaks (http://day32.com/MySQL/http://day32.com/MySQL).