/*----------------------------------------------------------------------------- Copyright (C) 2000, 2001, 2002, 2003, Alan Kennington. You may distribute this software under the terms of Alan Kennington's modified Artistic Licence, as specified in the accompanying LICENCE file. -----------------------------------------------------------------------------*/This software package is open and free. Please read the LICENCE file for precise details. |
DISCLAIMER. The author of this software disclaims any express or implied guarantee of the fitness of this software for any purpose. In no event shall the author of this software be held liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. |
The bwshare module has been developed and tested under SuSE 6.2, SuSE 7.1
and Redhat 5.2.
Some people have used it with FreeBSD 4.1 and Solaris 2.6. The current work-in-progress version of bwshare is 0.1.3. (This means that version 0.1.3 may change every day until it is frozen.) This should work with Apache versions 1.2.13+, 1.3.x and 2.0.44.
Here is my PGP public key.
|
The Apache shaping module ``bwshare'' uses a form of ``statistical shaping''.
This means that the software measures the statistical behaviour of the subscriber in the past, and uses this as a basis for controlling the current access to resources by the user. The principal algorithm used in mod_bwshare is the ``token bucket''. This module is quite reliable (with Apache 1.3.26 anyway). I ran it for 7 months from July 2002 to February 2003 without problems. The amount of data handled during those 7 months was about 7 GBytes. The only thing that stops it is an electricity failure or a syntax error in the httpd.conf file when I modify it and restart httpd. |
2000-12-20:
It seems that my bwshare Apache module is now superseded by mod_throttle by Anthony Howe. He's done a more professional job, has many more features and offers better control of the module parameters. You can't even take a tea-break in this industry without someone overtaking you!
2002-9-7:
|
Installation for Apache 1.2.13+ and 1.3.x: To install mod_bwshare with static linkage, create a directory apache/src/modules/bwshare in your apache source tree. Then copy Makefile.tmpl and mod_bwshare.c to the apache/src/modules/bwshare directory. The parameter --activate-module=src/modules/bwshare/mod_bwshare.oshould be used with the "configure" command in the top-level Apache source directory (in addition to any other command line arguments you normally use).
If there are any problems with the Makefile.tmpl file, compare it with the
Makefile.tmpl file in other modules, e.g. in apache/src/modules/example.
The following line may be suitable in the httpd.conf file.
AddModule mod_bwshare.cThe following lines may be included in httpd.conf so that the paths /bwshare-info and /bwshare-trace will invoke the corresponding handlers. Then you can click on http://www.yourdomain.com/bwshare-trace to monitor the progress of the module. <IfModule mod_bwshare.c> # Some bandwidth control parameters. BW_tx1cred_rate 0.067 BW_tx1debt_max 30 BW_tx2cred_rate 1000 BW_tx2debt_max 1000000 <Location /bwshare-info> SetHandler bwshare-info </Location> <Location /bwshare-trace> SetHandler bwshare-trace </Location> </IfModule>The following parameters are defined for control of the mod_bwshare module. These parameters are applied to each client IP address independently.
See also my notes on installing Apache 1.3.23 with PHP 4.1.2 and bwshare 0.1.2. |
Installation of bwshare version 0.1.2 for Apache 2.0.16:
These instructions seem to work with Apache 2.0.44 for bwshare 0.1.3.
To install this software, create a directory apache/modules/bwshare in your
apache source tree.
LTFLAGS="$LTFLAGS -export-dynamic"If "autoconf" causes this line to appear in your "configure" file, you will have to remove it or comment it out. I have no idea how this bug gets in there. The parameter --enable-bwsharemust be used with the "configure" command in the top-level Apache source directory (in addition to any other command line arguments you normally use) if you choose the `no' option in the config.m4 file.
If there are any problems with the Makefile.in or config.m4 files, compare them
with the corresponding files in other modules, e.g. in
apache/modules/experimental.
The following line is not suitable in the httpd.conf file.
AddModule mod_bwshare.cThe following lines may be included in httpd.conf so that the paths /bwshare-info and /bwshare-trace will invoke the corresponding handlers. Then you can click on http://www.yourdomain.com/bwshare-trace to monitor the progress of the module. <IfModule mod_bwshare.c> <Location /bwshare-info> SetHandler bwshare-info </Location> <Location /bwshare-trace> SetHandler bwshare-trace </Location> </IfModule>See also my notes on porting an Apache module to version 2.0.16. |
bugs
|
Purpose, principles, philosophy. The purpose of this module is to give the web site operator some control over bandwidth utilization by individual client hosts. The `bwshare' module temporarily blocks access by excessive users. This is aimed especially at users who download whole websites at great speed. Excessive speed is considered bad etiquette for search engine robots.
The guiding principle in this module is that two categories of clients should be
allowed unhindered access: human users and well-behaved search engines.
There are many actions which a throttling module can take when an excessive
user is identified.
Currently, the module bwshare has the following features.
Just as in IP ``differential service'', a general bandwidth sharing module must (1) classify the traffic (e.g. according to client IP address), (2) measure the traffic (e.g. with leaky buckets tx1 and tx2), and (3) take appropriate actions (e.g. shape/police/arbitrate the traffic). |
Current things to do.
|
Some notes on development:
The main objective of this software is to provide the means to balance and/or limit bandwidth demands by web clients. As a by-product, this module also has the ability to inform an operator of the current usage of an Apache web server. In other words, it has a monitoring function. A manual may be provided in the form of a TeX document some day.
The tx1debt and tx2debt measures in the bwshare_trace window are
measures of `greed'.
|
Previous versions of this package (historical interest only).
Version 0.1.1 works for Apache 1.3.x, but not for Apache 2.0.x. Version 0.1.2 should work for Apache 1.2.13+, 1.3.x and 2.0.16. Version 0.1.3 should work for Apache 1.2.13+, 1.3.x and 2.0.44.
Do not use version 0.1.0 for long run-times.
Clearly the double-arithmetic is faster than long-long. So there's no space or time advantage in using long-long. |
Note that there is some software
MM which is designed for
portable shared memory usage between httpd child processes.
The MM software might be a good way to ensure portability across operating systems. For more Apache modules, see the Apache module registry. For other bandwidth management modules, see the Apache Overview HOWTO. |