slow loading WordPress site - high CPU due to MySQL
Linode 512
32-bit Ubuntu 10.04 LTS
Apache 2.2.14
PHP 5.3.2 with APC
MySQL 5.1.41
I'm running
<ifmodule mpm_prefork_module="">StartServers 1
MinSpareServers 3
MaxSpareServers 6
ServerLimit 15
MaxClients 15
MaxRequestsPerChild 3000</ifmodule>
That fixed the swap issue, but now the CPU is going berserk. It looks like this:
~~![](<URL url=)http://i.imgur.com/9AJRo.png
It's pretty much all due to MySQL, too. I've been trying to tweak it, but it doesn't seem to be helping. Here are my settings:
key_buffer = 8M
max_allowed_packet = 1M
thread_stack = 128K
thread_cache_size = 8
max_connections = 100
table_cache = 128
query_cache_limit = 1M
query_cache_size = 32M
They have a decent amount of traffic, but it's not outrageous by any means (it's on the order of 2000-6000 hits a day). I don't really know what to do right now. I've also installed Quick Cache
5 Replies
@Fangs404:
I just uninstalled APC because my Apache error log was filled up with tons of these: "[apc-warning] Unable to allocate memory for pool." However, that doesn't seem to have fixed the issue.
Removing your PHP cache is going to lead to more load on your database, not less.
You should increase apc.shmsize to the point where the cache isn't constantly getting full.
@Fangs404:
It's pretty much all due to MySQL, too. I've been trying to tweak it, but it doesn't seem to be helping. Here are my settings:
Most of those are pretty low, especially keybuffer, assuming your tables are all MyISAM. You probably want to lower maxconnections.
You might want to try a tool like mysqltuner
skip-innodb
tmp_table_size = 64M
max_heap_table_size = 64M
key_buffer = 8M
max_allowed_packet = 1M
thread_stack = 128K
thread_cache_size = 8
max_connections = 75
table_cache = 128
query_cache_limit = 1M
query_cache_size = 64M
Even after changing this stuff, though, there's still not really a difference. It's still responding pretty slowly as you can see.
After I restart MySQL or Apache (either one), the site responds really fast for about 30 seconds, and then it resumes responding super slowly. Why would that happen?
Thanks for the help!
Also, often MySQL is hit hard from poor DB design with an un-necessarily large number of queries performed. It pays to tune your code and reduce the number of queries that need to be made.