1 May 1998. SRE_BALANCE: A Load Balancer for SRE-http SRE_BALANCE is a load balancer "addon" for SRE-http. It replaces the generic load balancer that comes with SRE-http. Alternatively, you can use a SREBLNCE.80 -- a special small & quick filter that will balance ALL requests (say, to a set of servers that are running SRE-http) -- see the bottom of this document for further details. **** Installation and use To install and use SRE_Balance, you must a) Install a few files b) Modify an SREFILTR.80 parameter c) Create an SRE_Balance initialization file a) Installing To install SRE_Balance you must copy a few files to your GoServe/SRE-http directory, and then replace the "backup server module": 1) Unzip SRE_BLNC.ZIP to an empty subdirectory 2) Copy SRE_BLNC.CMD and SRE_BLNC.RXX to your GoServe working directory 3) CD to your "GoServe/SRE-http LIB/ directory (say, D:\GOSERVE\LIB) and rename BACKSRVR.SRF. For example: D:\GOSERVE\LIB>ren backsrvr.srf backsrvr.ori 4) Copy SRE_BLNC.CMD to BACKSRVR.SRF. For example: D:\GOSERVE\LIB>copy ..\sre_blnc.cmd backsrvr.srf 5) Shutdown GoServe, clear macrospace (or reboot), and restart GoServe. To clear macrospace, you can use the MSPACE.CMD program (in the LIB\ directory). For example: D:\GOSERVE\LIB>mspace d b)Enable SRE_Balance: Actually, this step should be done before "restarting Goserve". 1) Using the EDITSREF programs (that comes with SRE-http), or with your favorite text editor, change a parameter in INIT_STA.80: LOADTHRESHOLD=nn where nn is a positive integer The LOADTHRESHOLD variable is the "minimum threshold" at which SRE_BLNC will take effect. For example, LOADTHRESHOLD=1 means "check all requests for possible load balancing". Note that the BACKUPSERVERS variable is not used by SRE_BLNC. To use SRE_Balance: You'll have to create a SRE_BLNC.INI file in the GoServe working directory. You can use SRE_BLNC.SMP file as a template. Having done the above, when you next startup GoServe/SRE-http, the generic load balancer will be replaced with SRE_Balance. SRE_Balance uses a daemon to expedit throughput, which will be launched as one of the SRE-http initialization actions. c) Create an SRE_Balance initialization file For SRE_BALNCE to be useful, you must create the SRE_BLNC.INI instructions file. The following briefly describes the structure of this file -- please see the sample (SRE_BLNC.SMP) for more details. Each entry in SRE_BLNC.INI should have the following structure host_nickname// sel min_clients url1 priority1 , .. , urnlN priorityN here: host_nickname : Optional item. Use this entry only for requests to the host corresponding to the host_nickname. sel : Required. The request selector will be compared against a_sel. If it matches, then this entry is used. You can include * as wildcards. min_clients : Required. Minimum number of clients (currently active); if there are few that min_clients active, load balancing will NOT occur. url1 priority1 , , urlN priorityN : Url1 is required. A comma delimited list of URL and PRIORITY pairs. The request selector will be appended to one of these URLn values. Thus, a request selector of: /FOOBAR.HTM and a URL1 of http://wow.net/foos/ will cause a "load balancing redirection" to http://wow.net/foos/foobar.htm. Note that a / is added to the end of urln (hence, you can NOT redirect to a document, but you can redirect to an explicit directory). You can specify multiple urls; the [optional] priority's are used to randomly select which url to redirect to (with higher priorities more likely to be accepted). Note that if a "priority" is not assigned, a priority of 1 is assumed. *** SREBLNCE.80 -- the balancer-only filter If you have an especially busy site, you may find that most of your requests are (or could be) "balanced". In such cases, it's silly to use SRE-http (with all it's overhead) just to redirect requests. Rather, a small and simple filter, whose only job is to "balance", should be used. SREBLNCE.80 is an example of such a filter. It will redirect all requests, using host name and selector to decide which (set) of servers to redirect to. The idea is to have some small (but perhaps quick) machine that recieves all requests, and then redirects them to a set of larger machines that actually respond to the request. Thus, you should use SREBLNCE.80 as the GoServe filter on this "small quick machine", and SRE-http (or whatever) on the "larger" machines. SREBLNCE.80 does require some setup -- you'll have to edit some "user configurable parameters" at the top of SREBLNCE.80. At this time, we do not have a configurator, so you'll have to do it by hand (with your favorite text editor). The following describes these parameters. Note that they are "stem" variables used to create an array; please note the following notation: i) When a name of FOO.!BAR.n appears, the !BAR is NOT a typo -- be sure to include the !. ii) the n in FOO.!BAR.n refers to an integer. NICKNAME.0 Number of "host nickname entries" NICKNAMES.n.!host and NICKNAMES.n.!address The "host nickname entries. The n should go from 1 to NICKNAME.0. NICKNAMES.n.!Host should contain a "nickname" which is used in the DOIT entries (described below). NICKNAMES.n.!ADDRESS should contain an IP address. For "aliased" hosts, this MUST be the IP name EXACTLY as it will be included by the client's browser (on a HOST: request header). For "numeric hosts", use the numeric IP address (NOT the IP name). DOIT.0 and DOIT.!NICKNAME.0 Number of "generic" selector specific entries, and number selector specific entries for each "host". The NICKNAME refers to the NICKNAMES.n.!HOST entries; do NOT use the actual address. DOIT.n.!SEL DOIT.n.!SITES DOIT.n.WEIGHTS DOIT.!NICKNAME.n.!SEL DOIT.!NICKNAME.n.!SITES DOIT.!NICKNAME.n.WEIGHTS The selector to compare against, the list of sites to (possibly) redirect to, and weights for these sites: for both generic requests, and for requests to a specific host. VERBOSE Status message level: 0=none, 1=some, 2=a few. The !SITES and !WEIGHTS are equivalent to the URL and PRIORITY options described above. Also, you can include * in the !SEL entry. SREBLNCE.80 will first search "host specific entries" (if a NICKNAME is found). If there is no match for the selector in the appropriate host specific entries, the "generic" entries will be searched. The first match, wherever it may be from, is used -- no attempt is made to find a "best match". Notes: * the # of words in the !sites variable should match the number of words in the corresponding !weights * it's a good idea to have a "match all" (a * selector) entry as the last generic entry An example: nicknames.0=2 /* two nicknames */ nicknames.1.!host='main' /* the "canonical" address */ nicknames.1.!address='161.11.65.143' nicknames.2.!host='site2' /* an alias for this server */ nicknames.2.!address='www.oursite.net' doit.!site2.0=2 /* these refer to requests to the www.oursite.net host */ doit.!site2.1.!sel='*.gif' doit.!site2.1.!sites='imgs.hersite.net/imgs' /* redirect, relative to the /imgs directory */ doit.!site2.1.!weights=' 1 ' doit.!site2.2.!sel='/*' doit.!site2.2.!sites='www4.oursite.net www3.oursite.net/host1 ' doit.!site2.2.!weights=' 5 1 ' /* 1/6 of requests to to host1 directory under www3 */ doit.0=2 /* two default entries */ doit.1.!sel='samples/*' doit.1.!sites='www2.oursite.net:8080 www3.oursite.net ' /* you can use a different port */ doit.1.!weights=' 1 2 ' /* 2/3 of the requests goto www3 */ doit.2.!sel='*' /* all non-matching requests to to 8080, perhaps on same matchine? */ doit.2.!sites='w3.oursite.net:8080' verbose=1