Help with server slowing way down and going into swap
We have a Linode512 with Debian 6.0 and using Apache2 to run a Wordpress front side of a site and a phpBB3 forums area. The site is
The server is slowing down a lot at times. Using the Linode graphs I figured out it's IO spikes, mostly caused by memory going into swap.
I started watching the server with htop and did some research and realized it might be the MaxClients setting for MPM prefork that's letting memory run out. I backed the default number down from 150 to 30, but that seemed to make things worse. I currently have it at 80 and things are ok, but it still goes into swap.
It seems each process for apache is using about 16.8MB and the listed available memory is 497.
/usr/sbin/mysqld also consistently is using 10 processes each with 2.7% of available memory.
Just from reading, some things I'm considering looking at are lightpd and FastCGI.
Any opinions on what settings to change or things to install to help? Any input appreciated.
10 Replies
I have had good success running phpbb on lighttpd so that is definitely an option. Apache is generally a resource hog when it comes to RAM and switching webservers might help you out.
@Ghan_04:
APC might only use more memory since it's an opcode cache….
I have had good success running phpbb on lighttpd so that is definitely an option. Apache is generally a resource hog when it comes to RAM and switching webservers might help you out.
Yes, APC takes up some memory, but because it's a cache, it means you can keep a number of requests from hitting the database. In turn, you lower the maxclients because most users will be served quickly.
@glg:
Yes, APC takes up some memory, but because it's a cache, it means you can keep a number of requests from hitting the database.
APC doesn't help reduce database queries. It's not that kind of cache. Unless you use the variable cache functions, which very few people seem to do.
APC prevents the PHP runtime from compiling the same scripts over and over again. Half of PHP script execution time is spent compiling, so skipping this step can easily make your scripts twice as fast.
@hybinet:
@glg:Yes, APC takes up some memory, but because it's a cache, it means you can keep a number of requests from hitting the database.
APC doesn't help reduce database queries. It's not that kind of cache. Unless you use the variable cache functions, which very few people seem to do.APC prevents the PHP runtime from compiling the same scripts over and over again. Half of PHP script execution time is spent compiling, so skipping this step can easily make your scripts twice as fast.
FWIW, phpBB3 actually can use APC as a SQL result cache (as opposed to using its native filecache). Take a look:
Also worth noting is that if you're on a prosilver style with phpBB, you're calling style.php every pageload, which is pretty taxing with performance. Use a subsilver-based style, or hack phpBB itself to use a static version of the stylesheet - it WILL net you some performance, it drops the amount of processing per user pageload drastically.
But yes, on its own, APC only does opcode caching.
I want to let it run a bit to get a baseline, but will likely install APC.
I wonder if I need to optimize MySQL, though. There's 10 processes running (/usr/sbin/mysqld) and they seem to have grown a bit in size, now taking 5.1% of memory each. That's half my memory, although I know that's not a real number, as free memory is often greater than half. Any recommendations there?
@Obsidian:
FWIW, phpBB3 actually can use APC as a SQL result cache (as opposed to using its native filecache).
Thanks for correcting me there. Is this automatically activated when APC is installed, or does the admin need to change a setting?
@volantis:
I wonder if I need to optimize MySQL, though.
For basic tuning, nothing beats this script:http://mysqltuner.pl
@hybinet:
@Obsidian:FWIW, phpBB3 actually can use APC as a SQL result cache (as opposed to using its native filecache).
Thanks for correcting me there. Is this automatically activated when APC is installed, or does the admin need to change a setting?
@volantis:I wonder if I need to optimize MySQL, though.
For basic tuning, nothing beats this script:http://mysqltuner.pl
Apologies for the late reply - you need to change the acm setting (should be something that mentions ACM anyways) in the config.php file to get it to use APC for the cache module.