1

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.

Aleix
  • 119
  • 2

1 Answers1

0

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.

timmeyh
  • 968
  • 1
  • 6
  • 25
  • 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? – Aleix 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