I’ve a server at home on a ADSL connection which has 100kBytes/s of upload and 1.2MBytes/s of download as bandwidth.
Here is a quick way to limit the bandwidth used by Apache :
Install & enable (on Ubuntu):
sudo apt-get install libapache2-mod-bw sudo a2enmod bw
Configure (your apache virtualhost conf file like /etc/apache2/sites-available/default) :
<virtualhost *:80> #... other config stuf for the virtual host BandWidthModule On ForceBandWidthModule On BandWidth 192.168.0.0/24 0 BandWidth all 80000 </virtualhost>
Explaination :
- line 1 : Activate the mod for the virtualhost.
- line 2 : Set a directive so that the mod limit the bandwidth on all http request. (you can use an alternate config to limit only some mime type)
- line 3 : set no limit for computer on your local area network.
- line 4 : set a limit to 80KB/s to all other computer
Restart Apache so that the config is loaded and test :
service apache2 restart (or apachectl restart)
Test with Firefox on a large file. From my computer, I’ve first commented with a heading # the third line (BandWidth 192.168.0.0/24 0) and when it works, I uncommented it.
Sources
http://blog.mansonthomas.com/2009/02/limit-upload-bandwith-of-your-apache.html
http://codee.pl/cband_documentation.html