[英]How to solve high CPU load by apache? (ubuntu+ec2)
I'm setup a instance in Amazon EC2, a ubuntu 10.04 server running apache2, php5 and mysql. 我在Amazon EC2中设置了一个实例,一个运行apache2,php5和mysql的ubuntu 10.04服务器。
With less than 10 users using the system the server gets 20%, 30%, 40% of CPU load. 使用该系统的用户不到10人,服务器获得20%,30%,40%的CPU负载。
Using top I see in the firsts lines: 使用top我在第一行中看到:
11121 www-data 20 0 71940 20m 11m S |
11121 www-data 20 0 71940 20m 11m S | 22.6 |
22.6 | 1.2 |
1.2 | 0:00.68 apache2
0:00.68 apache2
10108 www-data 20 0 72196 22m 12m S |10108 www-data 20 0 72196 22m 12m S | 21.9 |
21.9 | 1.3 |
1.3 | 1:15.81 apache2
1:15.81 apache2
11122 www-data 20 0 71936 20m 11m S |11122 www-data 20 0 71936 20m 11m S | 7.3 |
7.3 | 1.2 |
1.2 | 0:00.68 apache2
0:00.68 apache2
10111 www-data 20 0 72196 22m 12m S |10111 www-data 20 0 72196 22m 12m S | 1.7 |
1.7 | 1.3 |
1.3 | 1:16.43 apache2
1:16.43 apache2
The CPU sum in this 4 lines are 53,5. 这4行中的CPU总和是53,5。
How can I see more detailed the processes? 我怎样才能看到更详细的流程?
How can I take a look into scripts running, the times it takes, the amont of processor each one consumes? 我怎样才能看看脚本运行,需要花费的时间,每个人消耗的处理器的数量?
Thanks. 谢谢。
I solved the problem by installing Apache mod Status - http://httpd.apache.org/docs/2.0/mod/mod_status.html . 我通过安装Apache mod Status解决了这个问题 - http://httpd.apache.org/docs/2.0/mod/mod_status.html 。 There you can see each PID on what URL is used.
在那里,您可以看到每个PID使用的URL。
Hope it helps anybody... 希望它可以帮助任何人......
One way of looking at what it's doing is to use lsof ( you may have to install it ). 查看它正在做什么的一种方法是使用lsof(您可能必须安装它)。 To see what the processes in your example are accessing you would do this:
要查看示例中的进程正在访问您,请执行以下操作:
lsof -p 11121,10108,11122,10111 lsof -p 11121,10108,11122,10111
This will show you all of the files that process has open. 这将显示进程已打开的所有文件。 Usually a high cpu on the apache process is due to something the website is trying to do server side.
通常apache进程上的高CPU是由于网站试图做服务器端的事情。
您可以在父进程上使用strace来更好地了解它的作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.