Ok I know this is a weird problem and may not be possible, so ideas would be appreciated.

Anyways, I want to find out how much bandwidth I am giving to each user. I identify a user when he logins to the website.

So basically for every request, I want to know how much bandwidth was used by that request. And if a user was logged in at that time, I will add the amount to his account.

Will be using codeigniter, though I doubt that makes a difference.

Everything will be on the same Linux based server with Apache, for now at least. 

Ideally I'd like a solution that's not limited to the type of hosting. 

Will be using either Google cloud or amazon AWS. If the solution is limited to google cloud or aws, it will work.