Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

As you can see in below, Apache is using a high amount of CPU.


  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM     TIME+ COMMAND
28577 apache    15   0 99676  53m 3488 S   21  0.2   1:13.67 httpd
28568 apache    15   0 99676  53m 3496 S   19  0.2   1:14.92 httpd
28608 apache    15   0 99676  53m 3428 R   19  0.2   0:28.28 httpd
28615 apache    15   0 99676  53m 3436 R   19  0.2   0:25.33 httpd
28616 apache    15   0 99676  53m 3440 S   19  0.2   0:25.83 httpd
28619 apache    15   0 99676  53m 3436 R   19  0.2   0:26.12 httpd
28635 apache    15   0 97.9m  54m 3416 S   19  0.2   0:24.86 httpd
28558 apache    15   0 97.9m  54m 3432 R   17  0.2   1:40.75 httpd
28560 apache    15   0 97.9m  54m 3496 R   17  0.2   1:40.02 httpd
28621 apache    15   0 97.9m  54m 3420 S   17  0.2   0:25.61 httpd
28641 apache    16   0 97.9m  54m 3428 R   17  0.2   0:21.52 httpd
28642 apache    15   0 99756  53m 3424 R   15  0.2   0:21.46 httpd
28643 apache    15   0 99676  53m 3424 S   15  0.2   0:21.59 httpd
28594 apache    15   0 99756  53m 3428 R   13  0.2   0:44.41 httpd
28618 apache    15   0 99676  53m 3420 S   13  0.2   0:26.15 httpd
28654 apache    15   0 99676  53m 3472 S   13  0.2   0:04.27 httpd
28575 apache    15   0 99756  53m 3436 R   11  0.2   1:14.02 httpd
28576 apache    15   0 99676  53m 3496 S   11  0.2   1:16.79 httpd
28634 apache    15   0 99676  53m 3436 S   11  0.2   0:25.36 httpd
28653 apache    15   0 99676  53m 3424 S   11  0.2   0:04.35 httpd
28574 apache    15   0 99676  53m 3440 S   10  0.2   1:13.05 httpd
28592 apache    15   0 99676  53m 3492 R   10  0.2   0:45.78 httpd
28595 apache    15   0 99676  53m 3432 R   10  0.2   0:47.02 httpd
28617 apache    16   0 99676  53m 3436 S   10  0.2   0:25.32 httpd
28620 apache    15   0 99676  53m 3432 S   10  0.2   0:25.35 httpd
28597 apache    15   0 99676  53m 3428 S    8  0.2   0:43.56 httpd
11345 mysql     15   0 2927m 198m 4472 R    4  0.6   1624:43 mysqld
    1 root      15   0  2036  648  552 S    0  0.0   0:16.97 init
    2 root      RT   0     0    0    0 S    0  0.0   0:48.50 migration/0
    3 root      34  19     0    0    0 S    0  0.0   0:26.72 ksoftirqd/0
    4 root      RT   0     0    0    0 S    0  0.0   0:00.00 watchdog/0
    5 root      RT   0     0    0    0 S    0  0.0   0:04.98 migration/1
    6 root      34  19     0    0    0 R    0  0.0   0:27.51 ksoftirqd/1
    7 root      RT   0     0    0    0 S    0  0.0   0:00.00 watchdog/1
    8 root      RT   0     0    0    0 S    0  0.0   0:15.42 migration/2
    9 root      34  19     0    0    0 S    0  0.0   0:26.50 ksoftirqd/2
   10 root      RT   0     0    0    0 S    0  0.0   0:00.00 watchdog/2

How should I go about profiling what is causing this high CPU usage and what can I do to decrease it?

share|improve this question
    
Please provide more information. For example, have a look at apache2 tag description : serverfault.com/questions/tagged/apache2 –  coincoin Oct 31 '12 at 9:21

1 Answer 1

Without more information the two most likely reasons for high CPU load from Apache are simply:

  1. High Traffic - A lot of incoming requests equates to a lot of Apache processes doing work.
  2. Slow PHP Scripts - Slow, poorly optimized, or even buggy PHP scripts can hog a lot of CPU quickly.

I would setup mod_status to enable the extended '/server-status' page which will tell you a lot more detail on what Apache is currently serving. From there you may be able to see if it is one client hammering the site, if it is one particular page that is timing out, or if too many requests are just beginning to bog down the site. There are many potential root causes and each has a different solution so I would try to find or narrow down the cause first.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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