Throttle Apache Bandwidth with mod_cband

The current version can set virtual hosts' and users' bandwidth quotas, maximal download speed, requests-per-second speed and the maximal number of simultaneous IP connections.

More information on mod_cband can be found at


In order to compile mod_cband, we must have apxs installed.

# yum install httpd-devel


Download and install mod_cband.

# cd /tmp

# wget

# tar xzvf mod-cband-

# cd mod-cband-

# ./configure

# make

# make install


This should have added the mod_cband module to /etc/httpd/conf/httpd.conf. To confirm this run:

# vi /etc/httpd/conf/httpd.conf


You should see something like this:

LoadModule cband_module       /usr/lib/apache/


Restart Apache

# /etc/init.d/httpd restart


mod_cband is now installed.


To improve performance of mod_cband add the following two lines to your httpd.conf directly under where the module is listed.


CBandScoreFlushPeriod 1

CBandRandomPulse On


Now it's time to start throttling the bandwidth and limiting connections.

First lets create the score board to keep track of connections.

# mkdir /home/YourUser/domains/

# chown apache:apache /home/YourUser/domains/


On DirectAdmin servers the vurtual hosts files are located at: /usr/local/directadmin/data/users/YourUser/httpd.conf


Edit the httpd.conf of the of the user you wish to limit the speeds or connections of.

# vi /usr/local/directadmin/data/users/YourUser/httpd.conf


Edit the httpd.conf to look similar to this:

<VirtualHost 111.222.333.444:80>






            DocumentRoot /home/YourUser/domains/

            CBandSpeed 10mbps 10 30

       CBandRemoteSpeed 5mbps 3 3

       CBandScoreboard /home/YourUser/domains/


  <Location /cband-status>

    SetHandler cband-status


  <Location /cband-status-me>

    SetHandler cband-status-me



The CBandSpeed directive limits the overall Apache performance for the vhost to a speed of 10mbps, max. 10 requests per second and max. 30 open connections.

The CBandRemoteSpeed is like the CBandSpeed directive, but it sets limits for any individual user (as compared to the overall settings made by CBandSpeed).

After your changes, you must restart Apache.


You can now view the bandwidth usage and open connections for by going to


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.


Was this answer helpful?

 Print this Article

Also Read

Kill User Processes

To kill all processes under a particular user; Login as root # kill -9 `ps -u UserName -o "pid="`

Set Server Time and Date

To set your server time and date on your Linux server. Login as root Set Time and Date: # date...

Use NTP to synchronize the system clock

If you find your system frequently going out you can you the NTP service to sync your system...

Securing tmp, dev shm

How To Secure /tmp and /dev/shm partition   Secure /tmp:   Make a 1GB file for...

How to lower your TTL just before an IP change

When changing the IP of a domain, end users will have the old IP of the domain cached at their...

Powered by WHMCompleteSolution