0

I am experiencing high CPU usage here is the stats i got from server, the consumption after every restart in 15 minutes go upto 100%, what could go wrong?

I have a wordpress copy installed on the server which does not have much traffic, here is the stats that i got from using top command in server.

top - 11:46:02 up 12 min,  3 users,  load average: 40.89, 16.03, 6.11
Tasks: 132 total,  41 running,  91 sleeping,   0 stopped,   0 zombie
Cpu(s): 24.3%us, 61.5%sy,  0.0%ni,  0.0%id,  4.0%wa,  0.0%hi,  0.0%si, 10.2%st
Mem:   2050896k total,  1988656k used,    62240k free,      284k buffers
Swap:        0k total,        0k used,        0k free,     4712k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
   31 root      20   0     0    0    0 R   39  0.0   1:35.53 kswapd0
  899 root      20   0 15988  172    0 S   14  0.0   0:05.00 irqbalance
  418 syslog    20   0  243m  600    0 S   13  0.0   0:06.85 rsyslogd
  944 mysql     20   0 1320m  53m    0 S   12  2.7   0:21.15 mysqld
 2357 root      20   0 17344  532  164 R   11  0.0   0:14.27 top
  960 root      20   0  246m 3816    0 S    3  0.2   0:08.18 php5-fpm
 2431 www-data  20   0  344m  64m  908 R    2  3.2   0:04.23 apache2
 2435 www-data  20   0  304m  63m  836 R    2  3.2   0:03.43 apache2
 2413 www-data  20   0  349m  63m  920 R    2  3.2   0:07.51 apache2
 2465 www-data  20   0  349m  64m  944 R    2  3.2   0:05.04 apache2
 2518 www-data  20   0  307m  41m 1204 R    2  2.1   0:01.37 apache2
 2406 www-data  20   0  346m  56m 1144 R    2  2.8   0:03.76 apache2
 2456 www-data  20   0  345m  55m 1184 R    2  2.8   0:02.67 apache2
 2373 www-data  20   0  351m  63m  784 R    2  3.2   0:11.09 apache2
 2439 www-data  20   0  306m  35m  916 R    2  1.8   0:02.51 apache2
 2450 www-data  20   0  345m  55m 1088 R    2  2.8   0:02.96 apache2
 2486 www-data  20   0  299m  10m  876 R    2  0.5   0:01.19 apache2
 2523 www-data  20   0  300m  27m  796 R    2  1.4   0:00.99 apache2

closed as off-topic by EEAA, Ward, mdpc, HopelessN00b, MadHatter Aug 24 '14 at 5:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – HopelessN00b, MadHatter
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    It might help to run top as the CPU usage goes up to 100% – ryekayo Aug 20 '14 at 15:59
  • I do not get access to SSH when the CPU is running at 100% – Ibrahim Azhar Armar Aug 20 '14 at 16:01
  • You can set up a cronjob to run top periodically throughout the day, it might catch in action. – ryekayo Aug 20 '14 at 16:02
  • 1
    Your top output seems to be pointing at resource exhaustion. Allocate some swap space when you can access your server again. kswapd is known to cause lock-ups when there's no swap available and your memory is being exhausted (which is common under apache/mysql, by the way). – Nathan C Aug 20 '14 at 16:03
  • How do i allocate the swap space? – Ibrahim Azhar Armar Aug 20 '14 at 16:05
5

From the top output, it is pretty clear that you need more RAM or more swap for the workload you are running.

The way I reach this conclusion is from the following:

  • The amount of free swap is exactly 0k
  • The CPU usage of kswapd is high
  • The amount of free memory, buffers, and cached are all fairly low.

When those conditions are present I have always seen performance improvement by adding a swap file or swap partition. A swap file can be created in a few simple steps. For example you could use these commands:

mkdir -m 700 /var/local/swapfiles
head -c100M /dev/zero > /var/local/swapfiles/1
mkswap /var/local/swapfiles/1
swapon /var/local/swapfiles/1

You can create another larger swap file afterwards. Initializing a big swap file when kswapd is acting up, can be pretty slow.

Having some swap is a good idea on most systems, and you currently have none. If you manage to fill up a GB of swap or more, then it might be you need to reduce memory consumption or add more RAM.

In top you can press shiftM to see processes ordered by resident memory pages. That can give a hint about what is using your memory.

Not the answer you're looking for? Browse other questions tagged or ask your own question.