Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Centos 6 web server (Apache-itk, PHP, MySQL) with ISPconfig. I have about 100 websites on this webserver, all of them belong to me. I must be able to track how much of resources (traffic, CPU, RAM) each site consumes and possibly a way to limit some sites in resources, or give priority to other sites. What's the best way to do it without using virtualization? How do shared web hosts manage their resources?


traffic: ISPconfig shows traffic usage (Sites->web traffic). That's enough for me.

CPU&RAM by Apache: Because each apache vhost runs under different user (MPM-itk), I just need to know how much each user consumes resources overtime. (I've tried atop, but haven't didn't get how to use it yet)

CPU&RAM by mysql: This is the hardest part! All mysql instances run under mysql user. How do I track mysql resources usage by each mysql user?

CloudLinux and BetterLinux seem very interesting, are there free alternatives to it?

share|improve this question

closed as off-topic by HopelessN00b Mar 8 '15 at 20:19

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

Are the tools that ispconfig gives you not enough? You can get monthly bandwidth, visits, and other things, but to control effectively the usage of CPU and Ram you'll need something like Cloud Linux. – NickW Mar 15 '13 at 14:21
Thanks, I've completely overlooked that option in ISPconfig. However, I'm more interested in CPU usage by Apache/MySQL for each site. The CloudLinux seems to be a little overkill for our needs, and it also costs money. Are there any free alternatives to Cloud Linux which require less system modification? I mostly need to monitor resources, I don't neccessary need to limit it. – Dmitri Mar 19 '13 at 12:21
Well, the only problem monitoring per site is that it isn't easy to find out which apache process is serving which site, if you can do that, you'll have finished 90% of the work, obtaining stats per PID is easy. – NickW Mar 19 '13 at 13:36
If you want to monitor only, or maybe have daily emails with the usage.. have a look at – NickW Mar 19 '13 at 13:42
That will get you the PID per apache process, in theory you can write one per VHOST, and with mod_logio, you can get a per byte report of traffic, you're going to have to do some work associating all this info though. – NickW Mar 19 '13 at 13:44
up vote 1 down vote accepted

CPU and memory accounting

Utilize cgroups, cpuacct and memory controllers in particular. They'll give you fine-grained statistics on resource usage. You might need to adjust your setup though, ensuring your processes are bound to relevant control groups (as your sites are running under different system accounts, this should not be hard to implement).

If using cgroups is not the case, you can also install psacct package and use sa -m command (enable accounting beforehand with accton). However, this method would only account for finished processes. On the bright side, this won't need any changes to your system except for the package setup and enabling accounting.

MySQL accounting

This is the hard one. As all your sites are served from one MySQL instance (if I understand you right), you cannot rely on per-process/user statistics as described above. Nevertheless some solutions do exist: both MariaDB and Percona Server can be used as a drop-in replacement for traditional MySQL. Either products include user statistics: in MariaDB and in Percona Server. This statistics can give you a brief overview on how your databases are utulized by different users.

You also should not ignore traditional approaches:

  • SQL process sampling (show full processlist) when you notice your database performance is congested;
  • do not ignore slow queries: enable slow query log and use mysqldumpslow script (it's included in MySQL distribution) on a regular basis.
share|improve this answer
Thanks, this seems as a good starting point. I'm thinking of switching to BetterLinux + Percona Server. I'll have to check how to integrate it with ISPconfig though. – Dmitri Mar 20 '13 at 10:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.