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.

I've got a website (I'd say poorly optimized as it's my own code and I've never optimized a website before) and now that it's getting more visits the server load increases to up to 4-5 when there are 50 users online.

The VPS uses WHM/cPanel

What I'd like to know if there is a way to see what is causing this (mysql, php, image loads, etc..) so I can start optimizing them point by point.

share|improve this question

1 Answer 1

You have a VPS and thus ssh-acces (I assume) to it you can just use top or htop to see which process is using up most of your resources.

In case you don't have ssh-acces to your vps you can make a php page and put the following in it:

$output = null;
exec('/usr/bin/top -b -n1', $output);
var_dump($output);

This will execute the 'top' command on your system 1 time and will print it.


Edit: Saw your comment. You can use:

ps -o '%cpu' $PID

to find the average CPU usage of the process over its life. The hassle is that you have to look up every PID.

share|improve this answer
    
Yes but this way I just see random processes going up and down. PHP goes up to 50% then to 0 mysql the same, etc... Is there a way to see an average of the CPU consumption when the load is high? –  Tebb May 27 '12 at 15:42
    
use "ps -o '%cpu' $PID" to find the average CPU usage of the process over its life. (edited also in the post) –  timmeyh May 27 '12 at 16:19

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.