What is Mod Backhand? Tutorial guide and help compiling

mod_backhand is project that allows seamless redirection of HTTP requests from one web server to another. This redirection can be used to target machines with under-utilized resources, thus providing fine-grained, per-request load balancing of web requests. Backhand is a project that was initiated in class at The Johns Hopkins University in The Department of Computer Science. After a simple proof of concept, written in C++, the project was pursued as a graduate qualifier project. A proof of concept was realized, but a deployable product was needed. In order for public use, testing and, ultimately, acceptance, we wished to provide drop-in functionality in the most popular web server on the net. mod_backhand was born. This drop-in module for the Apache Web Server provides a turnkey solution for intra-cluster redirection of HTTP on a per-request basis. The redirection is based on various system resources available within the cluster. This service is provided seamlessly, preserving remote host information for access/authentication purposes. As with the methodology of Apache, the redirection mechanism can be enabled or disable for individual directories. System resources are announced by the module to the cluster via ethernet broadcasts and/or IP multicasts. These resources are made available to the decision making algorithms that drive mod_backhand.

What Problems will Mod Backhand solve, and what’s different from other tools?

First, we must clear a common misconception. mod_backhand may allow you to better utilize your resources, but if your bottleneck lies in your bandwidth, you will not be able to push more information. mod_backhand cannot use more than 100% of your egress point(s) bandwidth. However, if you have intensive CGI scripts or your machines are too weak to individually process the incoming requests, then mod_backhand is a solution. There are other tools commercially and freely available to attempt to load balance incoming requests within a cluster of web servers. All of these tools come at a price, except mod_backhand. If mod_backhand is not enabled for a certain directory or if it decides not to redirect a request, there is no overhead, as it is a “part” of Apache (thanks to the module API and dynamically loadable shared objects). Simply put, mod_backhand, can attempt to remedy the incorrect assignment of requests. In a grossly oversimplified scenario of two machines: if an incoming request is directed at machine B, and mod_backhand finds the available resources for machine A greater than the cost of forwarding from B->A plus the available resources on machine B, then it will be redirected to A. This redirect comes at a small cost, but a calculated and understood cost that better utilizes available resources. mod_backhand can be used by itself or in conjunction with most load balancing tools: Cisco’s LocalDirector, LinuxDirector, naive DNS tricks (round robin of multiple IPs). The advantage of mod_backhand over these lower-level (OSI) tools, is that it works on a per-request basis. All of the previously mentioned tools work on the TCP/IP level, handling connections not requests. This is a concern when using the pipelined (multiple requests per connection) HTTP 1.0 (and 1.1) protocols.

How mod_backhand Works

Backhand is built on top of the standard module API provided by Apache. The guts of this are available via source code, but you can also look at an implementation overview of mod_backhand. Some interesting implementation designs in this project are that of candidacy functions rather than strict determination functions. This combined with the ability to cascade functions, provides extremely configurable run-time configuration alternatives while maintaining speed in the decision making process.

Where can I get assistance in setting up mod_backhand on all my webservers?

Well, as it is open source, you can partially help yourself. But, if you require something more, help is available. After designing and testing this software, our group has learned to tackle certain obstacles. If you need to fine tune a cluster or make use of some of the features in Backhand for motives other than load balancing, we can help. This project was developed at The Center for Networks and Distributed Systems at The Johns Hopkins University, contact us and we will work something out.

Help and Steps in Compiling

This is pretty much verbatim from the INSTALL file included in the source distribution. For those of you who don’t have perl… Hours were invested making sure that all of this can be done with standard unix utilities (sh, cut, sed, wc, dc) mod_backhand is not very large, so it doesn’t have a stand alone install process. Run ./precompile to start the whole process off. Once this script completes successfully, you can just go to the apache source tree and ./configure like you would have without mod_backhand. (you will need to –enable some things, but an example is provided) ./precompile installs mod_backhand in your apache source tree and updates the various files to allow you to use the ./configure script accompanying apache. An example ./configure command line is displayed after successfully running the precompile script.

# cd /var/tmp
# ls
apache_1.3.6.tar.gz
mod_backhand.tar.gz
# gzip -d < apache_1.3.6.tar.gz | tar xf -
# gzip -d < mod_backhand.tar.gz | tar xf -
# ls
apache_1.3.6
apache_1.3.6.tar.gz
mod_backhand-1.0
mod_backhand.tar.gz
# cd mod_backhand-1.0
# ./precompile ../apache_1.3.6/
Copying source into apache tree...
Copying sample cgi script and logo into htdocs directory...
Adding to Apache's Configuration.tmpl...
Nullifying extra shared libraries for Linux
Modifying httpd.conf-dist...
        creating insertion....
        integrating insertion with original...
Updating Makefile.tmpl...

Now change to the apache source directory: ../apache_1.3.6/ And do a ./configure… If you want to enable backhand (why would you have done this is you didn’t) then add: –enable-module=backhand –enable-shared=backhand to your apache configure command. For example, I use:


   ./configure --prefix=/var/backhand --enable-module=so \
         --enable-module=rewrite --enable-shared=rewrite \
         --enable-module=speling --enable-shared=speling \
         --enable-module=info --enable-shared=info \
         --enable-module=include --enable-shared=include \
         --enable-module=status --enable-shared=status \
         --enable-module=backhand --enable-shared=backhand
# cd ../apache_1.3.6
# ./configure --prefix=/var/backhand --enable-module=so \
         --enable-module=rewrite --enable-shared=rewrite \
         --enable-module=speling --enable-shared=speling \
         --enable-module=info --enable-shared=info \      
         --enable-module=include --enable-shared=include \
         --enable-module=status --enable-shared=status \  
         --enable-module=backhand --enable-shared=backhand
Configuring for Apache, Version 1.3.6
 + using installation path layout: Apache (config.layout)
Creating Makefile
Creating Configuration.apaci in src
Creating Makefile in src
 + configured for Linux platform
 + setting C compiler to gcc
 + setting C pre-processor to gcc -E
 + checking for system header files
 + adding selected modules
    o rewrite_module uses ConfigStart/End
 + using -lndbm for DBM support
      enabling DBM support for mod_rewrite
 + using -ldl for vendor DSO support
 + doing sanity check on compiler and options
Creating Makefile in src/support
Creating Makefile in src/main
Creating Makefile in src/ap
Creating Makefile in src/regex
Creating Makefile in src/os/unix
Creating Makefile in src/modules/backhand
Creating Makefile in src/modules/standard
# make

(this is excluded for brevity)

# make install

(also excluded for brevity) The following is an excerpt from a vanilla install on a Solaris machine.

# cd /var/tmp
# ls
apache_1.3.6.tar.gz
mod_backhand.tar.gz
# gzip -d < apache_1.3.6.tar.gz | tar xf -
# gzip -d < mod_backhand.tar.gz | tar xf -
# ls
apache_1.3.6
apache_1.3.6.tar.gz
mod_backhand-1.0
mod_backhand.tar.gz
# cd mod_backhand-1.0
# ./precompile ../apache_1.3.6/
Copying source into apache tree...
Copying sample cgi script and logo into htdocs directory...
Adding to Apache's Configuration.tmpl...
Setting extra shared libraries for Solaris (-lkstat)
Modifying httpd.conf-dist...
        creating insertion....
        integrating insertion with original...
Updating Makefile.tmpl...

=========================== SOLARIS NOTE =============================== Backhand uses shared memory and the httpd children processes must attach to that memory. We choose to allocate that shared memory with user and group set to the apache user and group. All shared memory allocations happen during configuration. On Solaris, the User and Group directives in httpd.conf must be specified before the LoadModule and AddModule Directives for mod_backhand. If you do not do this, backhand will have no resource information for the cluster and will not operate correctly. You will see a error in the apache error logs: [error] (22)Invalid argument: shmctl(., IPC_SET, [-1,-1]) could not set segment #xxxx To remedy this, simply move the User and Group directives above the LoadModule and ShareModule directives Now change to the apache source directory: ../apache_1.3.6/ And do a ./configure… If you want to enable backhand (why would you have done this is you didn’t) then add: –enable-module=backhand –enable-shared=backhand to your apache configure command. For eaxmple, I use:

   ./configure --prefix=/var/backhand --enable-module=so \
         --enable-module=rewrite --enable-shared=rewrite \
         --enable-module=speling --enable-shared=speling \
         --enable-module=info --enable-shared=info \
         --enable-module=include --enable-shared=include \
         --enable-module=status --enable-shared=status \
         --enable-module=backhand --enable-shared=backhand
# cd ../apache_1.3.6
# ./configure --prefix=/var/backhand --enable-module=so \
         --enable-module=rewrite --enable-shared=rewrite \
         --enable-module=speling --enable-shared=speling \
         --enable-module=info --enable-shared=info \      
         --enable-module=include --enable-shared=include \
         --enable-module=status --enable-shared=status \  
         --enable-module=backhand --enable-shared=backhand
Configuring for Apache, Version 1.3.6
 + using installation path layout: Apache (config.layout)
Creating Makefile
Creating Configuration.apaci in src
Creating Makefile in src
 + configured for Solaris 260 platform
 + setting C compiler to gcc
 + setting C pre-processor to gcc -E
 + checking for system header files
 + adding selected modules
    o rewrite_module uses ConfigStart/End
      enabling DBM support for mod_rewrite
 + using -ldl for vendor DSO support
 + doing sanity check on compiler and options
Creating Makefile in src/support
Creating Makefile in src/main
Creating Makefile in src/ap
Creating Makefile in src/regex
Creating Makefile in src/os/unix
Creating Makefile in src/modules/backhand
Creating Makefile in src/modules/standard
# make

(this is excluded for brevity)

# make install

(also excluded for brevity)

FOLLOW US ON: