Mod - Bandwidth mod

The mod works as an output filter in the apache filters chain.
When a user start downloading something, the data goes through the mod. If there is a bandwidth limit, then the mod will start "splitting" the data into smaller pieces. Then it will start sending each piece with a small delay (less than 1 sec) between each piece, thus, reducing the speed the user downloads. This is useful for small web-hosting servers with limited outbound bandwidth (i.e. ADSLs customers).

Step 1

root# wget
root# tar -xvf mod_bw-0.7.tgz
root# cd mod_bw-0.7

Download and extract the file

Step 2

root# vi mod_bw.c

/* Compatibility for ARP < 1 */
#define apr_atomic_inc32 apr_atomic_inc
#define apr_atomic_dec32 apr_atomic_dec
#define apr_atomic_add32 apr_atomic_add
#define apr_atomic_cas32 apr_atomic_cas
#define apr_atomic_set32 apr_atomic_set

Comment this part in mod_bw.c
It help to avoid the bug for next step.

root# apxs -i -a -c mod_bw.c

To execute the module of mod_bw

root# cat /etc/httpd/conf/httpd.conf |grep mod_bw
LoadModule bw_module /usr/lib/httpd/modules/

Then you can see the module is loaded in apache if it is sucessed.

root# vi /etc/httpd/conf/httpd.conf
# Limit BW usage
BandWidthModule On
ForceBandWidthModule On
#Set Bandwidth all 20M for total collection
Bandwidth all 20480000
#Set Bandwidth all 2M for each connection minimum
MinBandwidth all 2048000

Edit httpd.conf and add this to Directory which bandwidth limitation is required.

Server is hosted by Alanstudio
Linux Operating System

Recommend screen resolution 1024 x 768 / IE / FireFox
Alan Studio © 2007 by Alan Cheung Hin Lun. All rights reserved.