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

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!


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


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/