Does Bandwidth throttle actual work ?

timekiller

Verified User
Joined
Jan 10, 2008
Messages
16
I know this seems like a silly question, but some tests I just ran are making me ask.

I created a new user with a single domain. I set the bandwidth limit to 1MB. I then put a 1.2MB file in the web root and downloaded it. Now if bandwidth limits were working the way I would expect, after I download the file once, bandwidth quota should be exceeded, and the site should be replaced by a "Bandwidth Exceeded" message. This is obviously not what happened. Instead I was able to download the file over and over again. It's now been several hours since I started the test and still no change.

I'm using apache 2.2, and see mod_cband is not installed which surprised me. The only thing I can figure is that there is a scheduled job that calculates bandwidth periodically - daily maybe ? I hope that's not the case since it means at minimum a client could go over bandwidth for a full day. If a site is getting hit hard (slashdot/digg) that would be a significant hit!

Soo - am I missing something ? Is my setup not configured right ?
 
I hardly see how a once a day bandwidth check can be considered a viable bandwidth limiter! If I allocate 5GB of bandwidth to a site, and that site gets slashdotted, or made popular on Digg, that site could push 20GB and not get shut down ?!?!?!? I've had my personal site featured on both, and believe me, it's no fun.

I'm sorry, but how does this not enrage anyone else ??? This may be the deal breaker for me...

I don't suppose anyone has written a plugin for mod_cband ? i just can't offer web hosting without REAL throttling...
 
A new message or response with subject:

User bwtest has used up 929% of his bandwidth and 0.06445% of his allocated disk space

*sigh* :(
 
Well, you could probably use disk quota's to limit GB on you drive, or maybe to something like

echo "action=tally&value=all" >> /usr/local/directadmin/data/task.queue

in some sort of cron to update more often. I think that probably somebody has a script for this soft of thing...
 
Yes, you can install cband if you wish. The apache compiled/installed is nothing speical, so any external guides will usually still apply.

I found this guide:
http://www.howtoforge.com/mod_cband_apache2_bandwidth_quota_throttling

For installing it on apache 2, which seems dooable (I have not testedit myself though).

Then for the per-domain virtuahost settings, you can either make global changes to the templates so everyone has them:
http://help.directadmin.com/item.php?id=2

Or only enable limits for indidual users:
http://help.directadmin.com/item.php?id=3

Or you can combine the 2 with variables to turn it on by default for everyone (in the templates), then use the per-domain section to set a variable that shuts it off for any domain you want.

Basic example, in the global templates, at the very top of each virtual_host*.conf file, add:
Code:
|?LIMITBW=yes|
then farther down within the VH, add the code you want, with an if statement:
Code:
|*if LIMITBW="yes"|
  CBandSpeed 1024 10 30
  CBandRemoteSpeed 20kb/s 3 3
|*endif|
which sets it on by default for everyone.

Then when you want to shut it off for one domain, go to:
Admin Level -> Custom httpd config -> domain.com
add this one line to the top textarea:
Code:
|?LIMITBW=no|
and save. BW limiting is now turned off.


Then even more, if you want this all to be in the package options, you can have numerical limits set by adding custom package items:
http://www.directadmin.com/features.php?id=479

and use the /usr/local/directadmin/scripts/custom/user_modify_post.sh to make any updates to your /usr/local/directadmin/data/users/username/domains/domain.com.cust_httpd ... and then issue an httpd rewrite to the task.queue, etc..

Related document:
http://www.directadmin.com/features.php?id=430
 
Also, FYI, the bandwidth option in DirectAdmin is not a throttle. It's a monthly usage limit, checked daily.

John
 
I understand that I can install mod_cband myself, and I have used the module enough to know it's abilities. Manually turning it on or off per user defeats the purpose of having a control panel. Rather than your suggestion, I would much prefer to create a script that reads the bandwidth value from /usr/local/directadmin/data/users/[user]/user.conf and update the user's httpd.conf with the proper mod_cband parameters so it matches their allocated bandwidth.

Such a script could be called from /usr/local/directadmin/scripts/custom/domain_change_post.sh so it updates the config any time the domain is modifued - here there are problems with this:

1) the bandwidth usage bar would not reflect the true usage without contantly running the tally task (ick)

2) There would be no way to keep the mod_cband count in sync with the tally count because mod_cband has it's own criteria on when it resets (apchae restarts for example can reset the count).

I can't rightly set a bandwidth limit in the control panel, and have mod_cband doing something that does not gel with the setting.

I understand that the tally is not meant to be a throttle, but it is meant to prevent a client from using more resources than he is allowed. The current implementation can not do this for single day hits, again, referring to a slashdotting or a Digg hit.

In short, your control panel is completely vulnerable to a massive bandwidth hit in a single day, and I see no way of fixing it, at least not with the functionality provided.

It seems like my only options are to just accept that if a site is slashdotted, I'm screwed - or set an arbitrary mod_cband limit that has nothing to do with the bandwidth limit in the control panel - neither option makes me happy.
 
I would think to do what you want requires more frequent tally checks, this in turn would increase the load on the server. I expect the way to do this is simply edit the crontab for tally and log rotations, there is obvious repercussions tho if you were to set it to a very low value. It also means apache is going to be restarted more often so people downloading large files for instance would be interrupted.
 
i noticed that. running the tally action also seems to queue the following:

action=httpd&value=reload
action=httpd&value=restart

loooks like it's a full restart rather than a graceful - so that is not an option either. I can't very well have my whole apache server restarting throughout the day.

This really bugs me because aside from minor complaints, DirectAdmin is the most feature full CP I researched. But the bandwidth thing just kills me. I'm trying to find a solution I can live with so I don't have to seek a refund :\

Maybe I'll try making a mod_cband plugin that would take over for the tally action. Disable the tally cron job, make the bandwidth bar pull from the cband status page. It could work I think, have to dig deeper into the api. I bought directadmin so I could spent LESS time doing this kind of stuff, not MORE :(
 
The immediate fix, if all you are really worried about is Slashdot, would be to block any referring requests from them. This way you accomplish what you want immediately and not have to worry about anything not being throttled.

Sure, some people will get around that but you kill off at least 50% right there. The regulars at slashdot are use to sites being shutdown due to to many requests and are not only use to it but accept that.

If your sites are getting creamed that bad that is the perfect "temporary" solution until a more suitable one can be found.

Bonus: no additional server load.
 
Back
Top