Apache: Limit Traffic per domain or file

apache-2.4bandwidth-controlubuntu-14.04

On my Ubuntu 14.04.2 LTS Server with Apache/2.4.7, I'm hosting a website. Soon, I plan to publish a large file for which I expect a high number of downloads.

I want to restrict the percentage of traffic allocated for downloads of this file so that the website will still run properly (e.g. only give it 90 of 100 Mbit/s).

The limit could be either for this one file or per subdomain (I can create a new one for this purpose).

So far, the only thing I've found is limiting the bandwidth per connection, but I want it to be a global limit for all connections of this one file.

I'm willing to install something other than Apache too, if necessary.

Best Answer

Use mod_bw and you can limit bandwidth per virtualhost entry in apache.

https://stackoverflow.com/questions/17009248/limit-bandwidth-per-apache-virtual-host