As I’ve spent the day doing some pre-emptive maintenance type stuff on our servers, I noticed that one of our servers appeared to have way slower ping times than normal from our other servers.
Taking a closer look I also saw that the logs said it having timeout problems talking to our database server.
A quick look at the server logs showed that the server in question was using 100% of its bandwidth for the last hour or so according to Monit.
A quick check with ntop (excellent web based network analysis statistics) and iftop (console based network traffic analysis) confirmed that 99.5% of the bandwidth was going to HTTP requests.
Strangely enough, the server wasn’t even stressed at all (I guess I’ve overspecced that one!)
I installed the apache2 module server-status ( a2enmod status, apache2ctl restart), and took a closer look at where the requests were going to.
In this case, all the requests were going to a single domain, to the detriment of other clients on the same server.
I decided to take a look at limiting the maximum bandwidth that that domain could use. I’ve used mod_bandwidth in the past for limiting apache virtual hosts, but sadly, it seems to have stopped development, so I took a look at whats currently available for apache2.
A few minutes googling later, I decided on installing mod-cband.
In debian, its fairly simple to install: (i’m assuming apache2 here)
apt-get install libapache2-mod-cband
apache2ctl restart
Now I had it installed, I had to configure it.
A quick read of the documentation shows that it needs some additions to the apache configuration.
I added this to my /etc/apache2/httpd.conf
CBandScoreFlushPeriod 1
CBandRandomPulse On
and then went to the virtual host in question, and added this:
CBandSpeed 1Mbps 10 200
The first number 1Mbps is how much total bandwidth the domain can use.
The second number is how many requests a second the domain can use.
The third number sets the maximum number of client connections to that domain.
I restarted apache2 – apache2ctl restart, and took a look at the excellent statistics provided by mod_cband
http://[theserverinquestion]/cband-status?refresh=15
…and then tweaked the CBandSpeed numbers based on what i was seeing (the values in the example above represent the optimum for the traffic i was seeing).
Any excess visitors over the (quite generously high) limits for that specific domain will see a 503 error, which can be customized to a page letting them know to come back later, as the server has exceeded its bandwidth limits.
The official documentation for cband is here – http://cband.linux.pl/, although their website doesn’t appear to be working currently (due to DNS timeouts).
A check of the logs showed that mod_cband was working nicely.

At around 8pm we started seeing heavy traffic (the far right), which started saturating the link about an hour later.
Once I’d installed mod_cband, and limited that domain, the traffic load dropped nicely.
Note that this server also acts as a backup server, so the increase in receive traffic at midnight is normal (the dip in the left side).
Conclusions:
Checking logs is a necessary evil
I also need to add some additional warning emails to the servers to notify me when things like this happen.
I already do this for some things like load, security scans, and failed logins, so its one more thing to monitor!
I’ve taken a look at this script here – http://sws.dett.de/mini/VHost_Traffic/ and will probably implement that at some point so I can see the biggest bandwidth usage in terms of client sites on a daily / weekly basis, with a view to moving them to a different server, and charging appropriately (yay, money!)
The good news is that it looks like the server in question can easily sustain slashdotting.
Post comment
Archives
- December 2011
- November 2011
- October 2011
- September 2011
- July 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
Categories
- Apple
- Badges
- BMW
- China Related
- Cool Hunting
- Exploits
- Firmware
- Food
- General Talk
- government
- IP Cam
- iPhone
- Lasers
- legislation
- MODx
- MySQL
- requirements
- Service Issues
- Tao Bao
- Technical Mumbo Jumbo
- Things that will get me censored
- Travel
- Uncategorized
- Useful Info
Most Popular Posts
- Samsung N310 (Samsung Go) Hackintosh Installation on Snow Leopard (9943)
- BMW Keys and Transponders E36 E38 E46 etc (EWS2) (7419)
- eFrontWPI - Wordpress integration Plugin for eFront (7338)
- IPCam Hacking - pt#2 (6796)
- IP Cam Hacking – pt#5 (4706)
Tags
Recent Comments
-
tryphon: It helped me to fix mine. I used a pair of pliers like you did and it worked fine. I drink a coffee typing...
-
mark: I have a ms10105 v4.1 moshisoft board and here is the pinout: 1 y stepper a (yellow) 2 y stepper a (white) 3...
-
Lawrence Sheed: Haven’t taken a deep look yet, probably next month can check it out. There are people who are...
-
mark: Yes…that moshi software is crap. I used the corel draw plugin for awhile but it only works about 20% of...
-
Kunlun: I tried to get my motorbike lesson after my car driving lesson, they answered me that I needed to wait 1...
Recent Trackbacks
- SISTEMAS O.R.P: Recuperar una cámara Zaapa CIP-RW después de un fallo de actualización
- Blog - DO Bots: Brookstone Rover AC13
- How can I stop Pop3 Brute Force attacks: need to create a regex, and add it to fail2ban Here is a guide....
- shanghailoz is our latest member! -:
- Probleem bij installatie op Samsung N310:



ICP Permit
Webmail
Newsletters
Support
