Bandwidth Controlling for Apache2 (Lenny)

Sometimes its usefull to throttle your bandwith within apache. There are two modules available mod_cband or mod_bw.

I just tested mod_bw which can be downloaded here: <a href="http://www.ivn.cl/apache/">http://www.ivn.cl/apache/</a>;

Installed Apache Versions:

ii  apache2-mpm-prefork  2.2.9-10     Apache HTTP Server - traditional non-threade
ii  apache2-prefork-dev    2.2.9-10     Apache development headers - non-threaded MP
ii  apache2-utils                2.2.9-10     utility programs for webservers</blockquote>
  1. apt-get install apache2-prefork-dev

  2. download and extract mod_bw-0.8.tgz

  3. sudo apxs2 -i -a -c mod_bw.c

  4. Add the following line to httpd.conf:

LoadModule bw_module /usr/lib/apache2/modules/mod_bw.so
  1. Add limitation to VirtualHost (sites-available/default)

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        BandwidthModule On
        ForceBandWidthModule On
        Bandwidth all 10240
        MinBandwidth all -1

        DocumentRoot /var/www/
        <Directory />
                Options +ExecCGI +Includes
                AllowOverride None
                Allow from all
        </Directory>
        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined
        ServerSignature On
</VirtualHost>

Another blogpost that contains also an how to based on mod_cband http://www.uno-code.com/?q=node/64.