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?




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.).

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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