logo logo

Controlling your visitors/users bandwidth usage and speed using mod_cband

Again, I’m using my beloved Debian 6 squeeze distribution to test this tutorial.
What is mod_cband? Directly taken from the one that maintain this piece of work:

mod_cband is an Apache 2 module provided to solve the problem of limiting users’ and virtualhosts’ bandwidth usage. The current versions can set virtualhosts’ and users’ bandwidth quotas, maximal download speed (like in mod_bandwidth), requests-per-second speed and the maximal number of simultanous IP connections (like in mod_limitipconn)

I recommend you to install this module into your server if your site providing download or stream service. Benefit after installing this module is: justice for all. For you as server owner: you can control the bandwidth usage and limiting your user’s download/stream speed, keep your server’s memory usage in control. For users: high availability server, no users dominate the bandwidth alone.

OK, let’s start:
install needed package (you need to compile mod_cband by yourself)

1
apt-get install apache2-prefork-dev make

download and extract mod_cband

1
2
wget http://sysdesign.pl/downloads/cband/mod-cband-0.9.7.5.tgz
tar xzf mod-cband-0.9.7.5.tgz

EDIT: it seems that site is not hosting mod-cband anymore, you can download mod-cband form my site instead: http://www.mp32u.net/mod-cband-0.9.7.5.tgz

go inside mod-cband directory and do ./configure

1
2
cd mod-cband-0.9.7.5
./configure

fixing Makefile; without doing this trick, you will get error message when trying to restart Apache2 afterwards. This is the error messages:

apache2: Syntax error on line 203 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/cband.load: Cannot load /usr/lib/apache2/modules/mod_cband.so into server: /usr/lib/apache2/modules/mod_cband.so: undefined symbol: truncf
Action ‘configtest’ failed.
The Apache error log may have more information.
failed!

edit Makefile produced by ./configure before. add “-lm ” after “APXS_OPTS=” and before “-Wc” on line 12. See screenshot:

cband Makefile

Watch for line #12

save it and then do “make&&make install

1
make&&make install

restart apache2

1
service apache2 restart

This isn’t enough. Now, configure your virtual host to use mod_cband. This just example virtual host configuration that I use:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
NameVirtualHost 74.117.233.146:80
<VirtualHost 74.117.233.146:80>
	ServerName mp32u.net
	ServerAlias www.mp32u.net nw.mp32u.net
	ServerAdmin achmad.zaenuri@hotmail.com
 
	DocumentRoot /var/www/mp32u
 
	ErrorLog ${APACHE_LOG_DIR}/mp32u.error.log
 
	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn
 
	CustomLog ${APACHE_LOG_DIR}/mp32u.access.log combined
 
	CBandRemoteSpeed 102400kb/s 4 5   # speed limit, number of request per second and max. number of connections
        <Location /bwm>
		SetHandler cband-status  # whenever http://www.mp32u.net/bwm is accessed, bandwidth statistics will be shown
        </Location>
</VirtualHost>

For more extensive and descriptive options, head to mod_cband documentation page

Example result: http://3gp.ytconv.net/bwm

bottom

No Responses to “Controlling your visitors/users bandwidth usage and speed using mod_cband”

Trackbacks/Pingbacks

  1. Ubuntu 12.04 Apache 安裝 mod-cband ,限制頻寬和連接數 « Zion's IT Pad - [...] http://www.ahowto.net/linux/controlling-your-visitors-users-bandwidth-usage-and-speed-using-mod_cban... [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

bottom