Track User Bandwidth With PHP Application
Asked Answered
T

1

1

I'm working on campus project using PHP and CodeIgniter.
It's only a project for my assignment.
Then it comes that i have to limit bandwidth used by user (of app, not linux user).
And i have no idea to implement this.
I wonder if someone know the logic or ever work on the similar tasks.
What basically i need is, how to track that user (system user, not linux user) bandwidth?
Should i count every requests and responses for that user?
How to count for imagse and static files download for specific user system?
Any hints is greatly appreciated.

Thaks
Ivan

Traject answered 15/9, 2011 at 8:5 Comment(0)
C
2

One of the only ways I can think of (using php) is to parse the access.log of the webserver, and add up the bandwidth for each client.

The next time a page is loaded and the client has reached a set limit you can then run what ever code you want.

Parsing the log each page load though does seem like it would be time consuming.

Thats how some website statistic programs get that info.

EDIT

Also some log files get archived at certain points, like mine gets a fresh start every Sunday at 6am so if a user was browsing during that time, their access history would disapear after 6, so saving the clients bandwidth in a database is a way to keep that information all the time

Cretinism answered 15/9, 2011 at 8:15 Comment(1)
That's sounds a good start. but parsing the access.log is indeed time consuming. otherwise i think i should setup a proxy for static files like facebook does.Traject

© 2022 - 2024 — McMap. All rights reserved.