I am a newbie to Linux OS and I had trouble on my drupal based sites which had turned out to be really slow. I am using 2 separate servers for hosting and MYSQL. On preforming the top command, I got the following result
top - 06:34:26 up 17:54, 1 user, load average: 4.54, 4.98, 5.36
Tasks: 79 total, 1 running, 78 sleeping, 0 stopped, 0 zombie
Cpu(s): 74.8%us, 23.6%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 1.7%si, 0.0%st
Mem: 4044336k total, 3963584k used, 80752k free, 21760k buffers
Swap: 1477940k total, 0k used, 1477940k free, 3530868k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1077 mysql 20 0 502m 181m 4124 S 98.8 4.6 549:02.28 mysqld
The CPU usage for mysql process is 99.7%. Does it mean that my processors are maxing out. What can be done to resolve this problem? Do I need to add more cores? However, on the contrary the load averages are low.
Im an absolute newbie and have picked up most jargon from books. Shall appreciate if someone can help.
Best Answer
You should check out why MySQL is so loaded, if you already have 2 or 4 cores that's probably not your problem. A good, cleverly optimized db system will be able to use much more ram before maxing out CPU time. Some things to look at before thinking about hardware upgrades are:
I am just guessing, but it seems that your system is spending too much time on the db itself (not much in I/O and not at all swapping or the like), so you probably should check out your indexes... maybe the db is just busy scanning tables because it hasn't the proper indexes to use for the queries you run (if that's the case, adding hardware won't help)
After that, if you still need more horsepower, I'd add more ram to the system, maybe up to 4GiB per core (ie, 16GiB if you run 4 cores), but that really depends on your dataset size and access patterns (mostly read, mostly write, etc...)