URL Mappings
Introduction
URL mapping is a powerful feature of the Zeus Load Balancer that enables particular web pages to be delivered by a specific machine in the cluster. This gives even greater control over the workload of each individual web server. Also, it enables clustering of websites where most of the content can be provided by all servers, but some specific areas must be handled by one machine.Mapping works as follows: You specify a list of regular expressions, together with the backend webserver that will deliver all URLs that match that regex. This list should be written to the file $ZEUSHOME/balancer/mappings and must be copied to each Balancer that is running. The mappings can be altered whilst the Balancer is still running - it will notice that the file has changed and reload the mappings as appropriate.
Syntax
<backend machine> <regular expression>with one regular expression per line. Blank lines and comments are allowed (comments are lines that begin with #).
Note that the regular expressions are only matched against the 'file' part of each URL. So, if a browser requests the page http://www.cluster.zeus.co.uk/foo/bar.html, the text '/foo/bar.html'is checked against all the regular expressions given.
For example, a valid mappings file could be:
# Map all image files to backend server 'mercury' mercury .*\.(gif|jp[e]g) # Everything in /products and subdirectories goes to backend 'venus' venus ^/products/Some important points to note
The syntax of the regular expressions used is that of POSIX extended regular expressions - see your UNIX documentation or the manual pages for regex.
The names of the backend webservers used in the mappings file must exactly match the names in the $ZEUSHOME/balancer/workers file (excluding the :port number). If the backend names do not match, the regular expression will not be used and an error is generated (see below)
Using URL mappings can be very costly to performance if the regular expressions that are used are complicated, or there are many different expressions. The fewer regular expressions used, the better. In fact, combining several regexs into a single expression will often improve performance. Regexs that do not begin with a fixed character (e.g. .*foo ) are expensive. Where possible, simplify the regular expressions.
The regular expressions are checked in the order specified in the file. Searching stops when the first regular expression matches.
If no regular expression matches, the request will be sent to any backend webserver, just as if there were no mapping rules.
Troubleshooting
After creating the mappings file, wait a few seconds to ensure that the Balancer detects that the file has changed, then check the error log of the Load Balancer. If there are any problems with the regular expressions or the syntax used in the file, the Balancer will report them. The error log is $ZEUSHOME/balancer/log/errors