I am working on a project that involves uploading flash video files to an S3 bucket from multiple geographically distributed sites.
Video files are about 2-3 MB each, and we send only one file (per node) every ten minutes, however, the bandwidth used should be limited to ~ 20 fps, since these nodes deliver streaming media to the CDN, and from for locations we can get a maximum load of 512k.
I studied the ASW-S3 gem, and although it does not offer any speed limits, I know that you can go through the input / output stream. With this in mind, I wonder if it is possible to create a stream with a speed limit that overrides the method read, adds speed limits to the logic (for example, in its simplest form, a call sleepbetween reads), and then calls to a super overridden method.
Another option I considered is to crack the code for Net :: HTTP and the speed limit in a method send_request_with_body_streamthat uses a loop while, but I'm not quite sure which one would be the best option.
I tried to extend the IO class, however this did not work at all, just inheriting from the class using class ThrottledIO < IOnothing did.
Any suggestions would be greatly appreciated.
source
share