How to calculate the transfer bandwidth consumption of a file stored in Amazon S3?

893 Views Asked by At

I'm developing a file hosting service in ASP.Net where the users will have a certain amount of storage and transfer bandwidth according to the plan they purchased.

Considering the fact that I will be using Amazon S3 to store the files, I'm looking for a way to track the amount of bandwitdth used by each file, so that I can associate this consumption with a certain user and notify him when he reaches the limit for his account.

How can I do that?

3

There are 3 best solutions below

1
John Sheehan On

Best I can tell, they don't offer that level of granularity for reporting. The only way I can think of to do it would be to host a proxy that grabs the files from S3, logs the bandwidth then returns it to the user. The unfortunate part of that is that you are paying for the bandwidth twice then just to meter it. Maybe an alternate pricing model would work?

0
rick schott On

You could write a routing frontend for the URL's being used. You can then track the image being created and how big it is. Now that you have that information you can just track the number of requests and calculate the bandwidth. It will be a tad slower to do the URL look-up, but the image will only have to be downloaded once to the browser.

0
Fozi On

You could enable logging, grab the log files and calculate each user's statistics.