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 http://codee.pl/cband.html
In order to compile mod_cband, we must have apxs installed.
# yum install httpd-devel
Download and install mod_cband.
# cd /tmp
# wget http://cband.linux.pl/download/mod-cband-0.9.7.5.tgz
# tar xzvf mod-cband-0.9.7.5.tgz
# cd mod-cband-0.9.7.5
# 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/mod_cband.so
# /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.
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/yourwebsite.com/public_html/scoreboard
# chown apache:apache /home/YourUser/domains/yourwebsite.com/public_html/scoreboard/
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:
ServerAlias www.yourwebsite.com yourwebsite.com
CBandSpeed 10mbps 10 30
CBandRemoteSpeed 5mbps 3 3
The CBandSpeed directive limits the overall Apache performance for the www.yourwebsite.com 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 www.yourwebsite.com by going to http://www.yourwebsite.com/cband-status
You can use the following units in the mod_cband directives:
* kbps: 1024 bits per second
* Mbps: 1024*1024 bits per second
* Gbps: 1024*1024*1024 bits per second
The default is kbps.
* 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.
* S: seconds
* M: minutes
* H: hours
* D: days
* W: weeks
The default is S.
Was this answer helpful?
To kill all processes under a particular user; Login as root # kill -9 `ps -u UserName -o "pid="`
If you find your system frequently going out you can you the NTP service to sync your system...
When changing the IP of a domain, end users will have the old IP of the domain cached at their...
How To Secure /tmp and /dev/shm partition Secure /tmp: Make a 1GB file for...
To set your server time and date on your Linux server. Login as root Set Time and Date: # date...
Powered by WHMCompleteSolution