5

I have a bunch of videos but I only want to limit the maximum download speed for these files to be 1mbps. How can I set this up (ideally in Apache but lighthttpd is an option)

thanks

2 Answers2

4

If you only want to limit the download speed per connection, without any regard for managing the totals or performing more fine-grained controls, the best way to handle this is to use Apache's own mod_ratelimit.

This example restricts everything under /files to 1Mbit/s...

<Location /files>
    SetOutputFilter RATE_LIMIT
    SetEnv rate-limit 1000
</Location>

I've researched and tried other methods and modules, and in this specific case, mod_ratelimit is hands down the easiest way to do this.

Download Speed Limit and Throttling for Apache 2.4.

rightstuff
  • 6,412
  • 31
  • 20
2

You can try mod_bandwidth or the more advanced mod_cband.

It appears the original site of mod_cband is offline. GitHub user "maiha" set up an archive of the original at mod_cband.

Quote from mad_bandwidth site:

Mod_bandwidth is a module for the Apache webserver that enable the setting of server-wide or per connection bandwidth limits, based on the directory, size of files and remote IP/domain.

Quote from mod_cband site:

mod_cband is an Apache 2 module provided to solve the problem of limiting users’ and virtualhosts’ bandwidth usage. The current versions can set virtualhosts’ and users’ bandwidth quotas, maximal download speed (like in mod_bandwidth), requests-per-second speed and the maximal number of simultanous IP connections (like in mod_limitipconn)

Here is a tutorial about how to use cband to limit download speed.

bhovhannes
  • 5,511
  • 2
  • 27
  • 37
  • thanks, ill look into that. do you know if theres anything on a per-connection basis? (I don't want to limit the whole vhosts entry or user to a maximum download speed, just the surfer on the website (each one having their own limit of say 1mbps)) –  Nov 13 '12 at 05:18
  • It is not obvious how to distinguish between connections in order to limit only for some of them. Another solution: you can host bandwidth limited version under separate port and redirect to bandwidth limited version if user has limit of 1mbps from main website using website code. – bhovhannes Nov 13 '12 at 05:30
  • cband is buggy. over throttled my server by a factor of 5 or 6 – Ray S. Mar 11 '14 at 08:30