Troubleshooting your busiest sites

If the problem isn't specific to a single site but all your sites are affected, this is almost always because one of your sites is causing problems which affects all the others. In cases like this, it can be hard to know which site is causing the trouble. Here are some tips on how to proceed in those cases.

Checking for active processes

This is the first step. Many times you can tell which site is causing trouble by simply checking your active processes. Log into your server via SSH and take a look at which processes are running. Let's say you see something like this:

[server]$ top -c
top - 14:37:35 up 10 days, 17:35,  3 users,  load average: 0.83, 0.89, 1.11
Tasks:  16 total,   1 running,  15 sleeping,   0 stopped,   0 zombie
Cpu(s): 34.7%us,  4.8%sy,  1.7%ni, 56.5%id,  0.9%wa,  0.2%hi,  1.1%si,  0.0%st
Mem:  32966092k total, 32546460k used,   419632k free,  6369232k buffers
Swap:  8000328k total,   228972k used,  7771356k free, 12650516k cached

PID   USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
8384  youruser  20   0 66984  11m 6852 S    1  0.0   0:03.62 php5.cgi
8385  youruser  20   0 66044  10m 6700 S    0  0.0   0:00.24 php5.cgi
10895 youruser  20   0 65940  10m 6848 S    0  0.0   0:00.92 php5.cgi
10917 youruser  20   0 65980  10m 6848 S    0  0.0   0:00.79 php5.cgi
7542  youruser  20   0 65956  10m 6860 S    0  0.0   0:00.51 php5.cgi
7818  youruser  20   0 65980  10m 6860 S    0  0.0   0:00.35 php5.cgi
7828  youruser  20   0 65988  10m 6860 S    0  0.0   0:00.33 php5.cgi
7917  youruser  20   0 66016  10m 6860 S    0  0.0   0:00.43 php5.cgi
8152  youruser  20   0 65976  10m 6856 S    0  0.0   0:04.21 php5.cgi 
8380  youruser  20   0 65932  10m 6848 S    0  0.0   0:04.03 php5.cgi
8386  youruser  20   0 66020  10m 6860 S    0  0.0   0:00.32 php5.cgi
10896 youruser  20   0 65908  10m 6848 S    0  0.0   0:00.66 php5.cgi
10919 youruser  20   0 65948  10m 6848 S    0  0.0   0:00.24 php5.cgi

In the above case, you can see that there are a lot of php5.cgi processes running under your user, but if you have more than one site that's less than helpful.

Assuming you’re running a PHP site, run the following command. If you’re not using PHP, just change the ‘grep php’ section to the language you’re using:

[server]$ lsof -u youruser | grep php | grep /home

Ignore any errors you see in the response. What you’re looking for is the list of open files for your PHP processes. You can then look closer into those files to see what the issue may be.

Finding your busiest sites

Sometimes the above method doesn't work well, which means you might need to investigate your busiest sites since those will likely be the ones causing the most trouble. The easiest way to find out which sites are your busiest is by checking the access.log file for each site – the larger it is, the more traffic it's getting (they're rotated daily). To do this, log into your account via SSH and run this command from your user's home directory:

[server]$ for k in `ls -S logs/*/http/access.log`; do wc -l $k | sort -r -n; done

This command prints a list of your most active sites. Visit the following article for further information:

See also

Did this article answer your questions?

Article last updated .