Getting the download count of a specific S3 object
I've got a number of S3 objects that are available to my customers. Since I'd like to bill my customers by usage, I wondered if there is any smart kind of way to get the number of times a given file has been downloaded?
Alternatively, I suppose I could parse the log files provided by S3, but with 10m+ fetches per customer this might be bit of a task.
Any ideas?开发者_StackOverflow中文版
If you let them download via HTTP then you could use a URL shortener service to redirect to your file (like goo.gl). I suppose they can handle load and they also provide some nice stats next to total clicks.
You could redirect through a script on your site that increments a count before redirecting to the S3 URL.
There'd be some assembly required and it needs some cleanup, but I wrote an app for this based on node.js and Couchbase. I need to update it a bit more, but it will count HTTP 200s based on object size rather than just hitcount alone (which is inaccurate) and I've just been updating it to aggregate HTTP 206s.
精彩评论