Knowledgebase
How to find out what part of the code is causing load?
Posted by Johnburk, 11-06-2010, 05:22 PM | I am trying to figure out what part of the php code is causing a high CPU usage. I tried tracing a process in WHM, but that gives hundreds of pages of non-understandable output.
Main >> System Health >> Process Manager >> Trace
Is there a way to find out what part of the code is using a high CPU?
For example for the top -c output:
|
Posted by Johnburk, 11-06-2010, 06:00 PM | With strace I get a 12M output file which is the same as the trace in WHM
strace -p 13724 -o /tmp/13724.out
|
Posted by YouHosting, 11-08-2010, 10:21 AM | Is it some custom written script?
Then search for big arrays, loops, and part where it makes external connections.
If few cases i experienced this problem it was kind of DDOS script that makes a loop from 1 to 65000 and each time opens a connection to random port.. It caused 99% cpu usage.
|
Posted by Johnburk, 11-08-2010, 10:34 AM | The problem is how can I search 15 websites with all of them having different php files and codes.
|
Posted by YouHosting, 11-08-2010, 11:18 AM | You can catch that script in this way: run 'nice top -c' on console.
As soon you see any 'nobody' process with high cpu usage copy it's PID and then immediately refresh the apache status on WHM. Search for that PID and you will see exact script which is getting that request.
|
Posted by Johnburk, 11-08-2010, 02:10 PM | Thank you. That only shows
OPTIONS * HTTP/1.0
|
Posted by Johnburk, 11-11-2010, 07:58 AM | I cannot image that a file causing the load cannot be traced. But it does seem that way.
Anyone else has a suggestion?
|
Posted by kevinnivek, 11-11-2010, 01:53 PM | viewing the strace output should provide more insight. that plus the top + pid + wcpu information , you should be able to narrow it down to which script.
there is also tools like apachetop which could proivde more insight.
|
|
Add to Favourites
Print this Article |
Also Read
powweb (Views: 660)