First things first, I'm calculating downspeed using
def downspeed
aria2_client.tell_active.inject(0) do |sum, download|
sum += Integer(download["downloadSpeed"])
end
end
Sampling this 10 times with 5s pause I get
[461418, 463992, 468939, 472702, 475559, 470763, 478367, 476623, 471814, 472302].
instance_eval { reduce(:+) / size.to_f } # => 471247.9
This is an average of 460 kilobytes. Currently there is no limit set and 460 kb is roughly my line limit. So things are working as expected. Theoretically, I should be able to halve this speed to roughly 200 kilobytes by issuing:
a.global_opts["max-overall-download-limit"] # => "0"
a.change_global_opt("max-overall-download-limit", "200K") # => "OK"
a.global_opts["max-overall-download-limit"] => "204800"
After 1 minute and 5 minutes I get the following samplings:
[787563, 687335, 737474, 616957, 379094, 261147, 762531, 712533, 713150, 528384]
# => avg: 618616.8
[241659, 295719, 204817, 291366, 306119, 229627, 515800, 438093, 409138, 354970]
# => avg: 328730.8
This just seems broken to me because both average above the limit I set for aria. Furthermore, I've used out-of-band monitoring tools like the iftop
command to see what the actual bandwidth consumption is. In both cases, it hovers around 460 kb which is my line speed.
It is worth noting that if I seriously restrict the usage (10K) then aria does actually limit it - but not to 10K!
[116286, 104248, 107772, 115253, 84493, 42524, 118660, 105615, 110290, 118871].
instance_eval { reduce(:+) / size.to_f } # => 102401.2 # 100 K!
I have a couple of questions:
- Is my download-speed-measuring function OK? Is there anything I can do to improve it?
- Am I doing something stupid with the max-overall-download-limit option?
Some points to note:
- All my downloads are added via metalinks: I call
addUri
with a http://foo.metalink
file.
- This is on Ubuntu 12.04 using the PPA. Aria is at 1.13.0.