Apache2: Limit simultaneous requests & throttle bandwidth per IP/client?

11,399

Solution 1

try to use http://opensource.adnovum.ch/mod_qos/ mod_qos now taking care of anything :)

Solution 2

http://www.cohprog.com/mod_bandwidth.html would take care of about 80% of what you need.

For shaping traffic, you might look at tc from http://lartc.org/

Share:
11,399
xentek
Author by

xentek

I help startups build amazing teams that ship great products.

Updated on September 17, 2022

Comments

  • xentek
    xentek over 1 year

    I want to limit simultaneous requests & throttle bandwidth per IP/Client on a single apache vhost. In other words, I want to ensure that this site, which hosts large media files, doesn't get hammered by someone trying to download everything all at once (just happened the other night).

    I'd like to limit the outgoing transfer speed overall for this site, as well as limit the number of connections a single IP can make to the server to a sane default (i.e. within normal browser limits for multiple requests so page loads aren't effected too much). Bonus points if I can actually scope it to file types (i.e. leave web files alone, but apply these rules to just the media files).

    We're running Ubuntu 9.04 on all the servers, and have two apache/php servers being load balanced via Round Robin by a squid proxy server. MySQL is running on its own box as well. We've got plenty of bandwidth to give them, so I don't really want overall caps, but just want to throttle the amount of memory/CPU it takes to serve this site. There are other sites on these servers that we don't want to apply these rules too, just want to keep this one from hogging all the resources.

    Let me know if you need more info! Thanks in advance for your suggestions!

    • xentek
      xentek about 14 years
      Not that it matters all that much to me, but mod_bw that is in the neighborhood that is in the Ubuntu default apt-get repositories.
  • xentek
    xentek about 14 years
    Are you using mod_bandwidth in production? Last update to that module was 2007(?) which I take to mean that its perfect, or development was abandoned. Checking out tc/lartc.org, which I saw recommended in other serverfault threads... this might be a bit above my head (more of a dev with sysadmin skills then any kind of networking genius).
  • Marlies
    Marlies about 14 years
    I have run it (and the predecessor mod_throttle - which does do 100% of what you need) for years. There really isn't that much to it. mod_throttle was pulled off the web some time ago but, you might be able to find a copy. I don't know if it was ever converted to apache 2.2. tc would allow traffic shaping which isn't really as difficult as you would think. The question would be whether or not you could shape traffic on a subinterface - I've only done it for a physical interface.
  • xentek
    xentek over 12 years
    I no longer work on the project the prompted the original question, but this module looks like it would have done the trick. Marking this as the accepted answer but with one caveat: I haven't tried mod_qos in production myself.