[BlueOnyx:11618] Apache-bandwidth CGI interface suggestion

George F. Nemeyer tigerwolf at tigerden.com
Fri Oct 26 17:36:02 -05 2012


The BX "apache-bandwidth" package uses the Apache mod_cband server module
to limit the web bandwith for each virtual host site.  It's pretty handy
if there's vhosts that generate tons of outbound traffic and you want to
even things out, or if you want to reserve some bandwith for other things
on your network.

Apache-bandwith adds a sausalito GUI 'Bandwidth Limits" section for each
vhost under "Site Management --> Services --> Web".  The section has a
checkbox for "Enable Bandwidth Limits", and a number entry field to enter
the kbps allowed for the individual site.

If enabled, CCE generates some lines lines in the virtual site's httpd
config file in /etc/httpd/conf/vhosts/siteNN :

  # BEGIN Bandwidth SECTION.  DO NOT EDIT MARKS OR IN BETWEEN.
  CBandSpeed 500 10 30
  # END Bandwidth SECTION.  DO NOT EDIT MARKS OR IN BETWEEN.

The line "CBandSpeed..." is either included or removed according to the
GUI check box, though "# BEGIN..." and "# END..." remain as placeholders.

The first number in the CBandSpeed command line is the overall kbps
allowed for the site.  It is obtained from the number entered in the GUI
entry field.  There's no default value provided, and a GUI error is thrown
if there no number is entered, or less than 10 is entered.

This seems to work OK as far as it goes.

However...

The second and third numbers are required in the command line syntax.
The second number is the 'Max number of requests per second" allowed, and
the third is the "Max total connections" allowed.

Unfortunately, these numbers are currently hard-coded into the handler:
     handlers/base/apache-bandwidth/bandwidth.pl
and thus can't be changed, since there's no entry fields provided for
them in the GUI.

For a busy site, especially with one having something like a page full of
many thumbnail images or lots of graphic bits typical of today's web
pages, the number of requests coming in and number of total simultaneous
connections can easily spike above the hard-coded limits and result in
'503 Service unavailable' server responses back to the viewer.  So having
the ability to easily change these limit values becomes important.

However, you can't change the auto-generated config file witout risking
having new values re-written with the handler's defaults whenever the
config file gets some other change.  If you put them in the siteNN.include
file, you have to use the entire command line, so there's a conflict of
directives, and the GUI won't necessarily reflect what the actual Limits
are.

Likewise, the sausalito handler hard-coded values could be edited, but
that means they would become the new overall system-wide defaults.

The solution is to provide the additional GUI fields to let the current
hard-coded values be customized for each site.

I'd respectfully ask that the handler include user changeable fields for
these values.  They can be pre-loaded with the current default values,
(and perhaps limited to some maximum value, though I don't know from the
CBand documentaton I've seen what, if any, maximum it might allow).

I'd also request a check box be included which would enable the bandwidth
status report web page which CBand can generate.  This would require the
following lines in the #BEGIN/#END BandWidth SECTION to be either included
or absent according to the user's check box choice (assuming Limits are
enabled):

   <Location /cband-status-me>
        SetHandler cband-status-me
   </Location>

These lines could be manually entered into the 'siteNN.include' file, but
it would be lots simpler to keep all the CBand-related things together,
and keep it CBand GUI control.

CBand also has lots of other commands (per-user limits, things to do if
limits are exceeded, etc.) but those seem much more complex, and are
probably less used than the GUI could easily accomodate.

So the new Bandwidth Limits GUI section would look like:

    [_]  Enable Bandwidth Limits                    <--- Existing
           Limit (kbps)       [_____]               <--- Existing
           Max Requests/sec   [___10]               <--- New
           Max Connections    [___30]               <--- New
           Enable web bandwidth status page at      <--- New
              <http://vhost/status-me>  [_]         <--- New

CBand also has lots of other commands (user limits, things to do if limits
are exceeded, etc.) but those seem much more complex, and probably less
used than the GUI could easily accomodate.  What I've requested at least
takes care of the minimum command line options needed to enable the basic
band limiting feature.

If I was a programmer sort, and had some grasp of how all the sausalito
magic happens, I'd be happy to hack it together.  Right now, it's mostly a
mystery, but it *seems* like it wouldn't be a massive undertaking.

Please give this some consideration.

=^_^=  Tigerwolf



More information about the Blueonyx mailing list