Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

Im a php developer and I would like to offer subdomain hosting,but need also to be able to calculate bandwidth for each subdomain.

For the subdomains creation I will use catch-all and wildcards etc to easily set these up.

The one thing im a bit stumped on is how to calculate bandwidth for each subdomain, is this possible within php? or are there better solutions for this perhaps using folders or something?

Also a script will be loaded under the subdomain, this will vary per user. Is it worth giving each user a new folder and their own script, or more easy to manage one script for all users? Any considerations here?



share|improve this question
up vote 1 down vote accepted

Your best bet may be to parse out the data transfer from the web server's log files. Whether each subdomain has its own log file or not shouldn't be important as long as there is some way to differentiate them (log the hostname of the request, for example). You can then aggregate the statistics and act on it accordingly. This will have the added benefit of tracking bandwidth used by page assets as well (javascript, css, images, etc.).

share|improve this answer
awesome answer, perfect, just what im looking for, thanks Justin :) – Ke. Jun 9 '10 at 21:29

Your Answer


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.