Manage Apache Download Speed and Traffic Limits

Administration, Linux System Administration, Operating Systems Add comments

I’ve been experimenting on how I can limit the download speed via Apache configuration. This method is good for file-sharing website and for hosting servers. In my case, I am using Centos 5.5 and Apache 2.2.3 + mod_cband

So, here’s what you will do… Assume you already installed the Apache.

  1. Install Apache Development libraries by casting “yum -y install apache-devel”
  2. Download “mod_cband” from or direct download link at

Follow steps (must be root mode)…

cd ~
tar xzvf mod-cband-
cd mod-cband-
make install

To check if successfully installed, type just like below and must have same result:

[root@localhost ~]# cat /etc/httpd/conf/httpd.conf | grep
LoadModule cband_module       /usr/lib/httpd/modules/

Then add the code below at httpd.conf then save and restart apache.

CBandScoreFlushPeriod 1
CBandRandomPulse On

Next is add a “scoreboard”

mkdir /var/www/scoreboard
chown apache:apache /var/www/scoreboard/

Final steps is create an vhost entry at /etc/httpd/conf.d just like this (in my case, I created as my vhost);

[root@localhost conf.d]# cat
<VirtualHost *:80>
    DocumentRoot /home/
    CBandSpeed 1024 10 30
    CBandRemoteSpeed 50kb/s 3 3
    CBandLimit 500M
    CBandExceededSpeed 128 5 15
    CBandScoreboard /var/www/scoreboard
    CBandPeriod 4W

    <Location /cband-status>
      SetHandler cband-status
    <Location /cband-status-me>
      SetHandler cband-status-me

    ErrorLog logs/
    CustomLog logs/ common

[root@localhost conf.d]#

After you created the vhost file, restart your apache.

You can check the status of certain vhost by accessing the URL:

or another status URL:

Further Explanation:

  1. CBandSpeed 1024 10 30 — Overall apache performance. Max bandwidth speed is 1024bits per secs. 10 requests per secs. 30 max connections
  2. CBandRemoteSpeed 50kb/s 3 3 — Individual apache performance. Max bandwidth speed is 50kb/s, max 3 requests/s and max 3 connections
  3. CBandLimit 500M — 500MB max bandwidth limit
  4. CBandExceededSpeed 128 5 15 — Bandwidth speed limit at 128kbps, 5 request/s and max of 15 connections
  5. CBandScoreboard /var/www/scoreboard — scoreboard location
  6. CBandPeriod 4W – time to refresh
  7. CBandExceededURL — if bandwidth exceeded, redirect to the specified URL.
You can use the following units in the mod_cband directives:

Transfer speeds:

    kbps: 1024 bits per second
    Mbps: 1024*1024 bits per second
    Gbps: 1024*1024*1024 bits per second
    The default is kbps.

Transfer quotas:

    K: 1000 bytes
    M: 1000*1000 bytes
    G: 1000*1000*1000 bytes
    Ki: 1024 bytes
    Mi: 1024*1024 bytes
    Gi: 1024*1024*1024 bytes
    The default is K.

Time periods:

    S: seconds
    M: minutes
    H: hours
    D: days
    W: weeks
    The default is S.


Download mod_cband file:

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in