Re: :-) Squid as a Load Balancer, . . . Yes!

Date: 16 May 97 12:31:42 -0700

Hi Daniel,
Thanks for your feedback! I agree that having the redirector perform a
function of some sort that will allow it to dynamically decide which server to
redirect to would be best!
Unfortunately I'm more of a "UNIX systems integrator", and not really a
programmer. I am pretty good at bourne shell scripts, which is what I wrote
the load balancing stuff in. My Perl is kinda weak at this point. I tried
hacking it in the shell to see if I could get the server selection to be more
dynamic, yet since I'm using The Perl URL rewriter, at startup Squid would
parse through the shell commands until it gets to the Perl script which is
what you would see running as the redirector process, i.e. even though my
redirector process was a shell script that then executed a Perl script, at
startup Squid immediately saw this and parsed through the shell stuff leaving
the Perl script as the actual redirector process that runs on the system.
This makes sense based on how Squid is designed, for speed I am sure they want
most of the redirector process sitting in memory ready to run???
A buddy of mine is good at Perl, and maybe this weekend he can lend some
assistance. Im not sure how this would work though for I'm not a Perl
programmer. If I had information available in a flat file, to make it easy
lets say I have a flat file that contains one entry which is the current host
with the least load. How could I dynamically read that hostname into the Perl
script as a variable each time the redirector is run? Or is Squid always going
to read in that variable at startup when it spawns the redirector processes?
If anyone knows more about this or can shed some light on this, I will be very
grateful! If I can work through this one issue, then Squid will make a good
load balancer!
Does anyone know if I can somehow just send a SIGHUP or some other SIG just to
the redirectors alone and not the entire Squid cache? SIGUSR ??
Thanks in advance!

Thomas D. Briglia voice:415-506-8212 pager:1-800-6-PAGEME
Internal Systems Engineering Services
Oracle World Wide Customer Support Viva BSD!!!

attached mail follows:

> The redirection based on load is accomplished by copying in a different
> version of the "redirector" program. Unfortunately to make this work you

> redundancy, yet I'm not sure how practical it will be if you had the
> thing frequently switching back and forth between servers, each time

> If anyone has an interest in my load balancing routines let me know and
> I will try to make the available anonymously.

        Why not inconvenience one user every 10 minutes for a few seconds
and save yourself the trouble of the SIGHUP by creating a more powerful
        I'm not sure what you have written the redirector in but working
off of the sample given in the Release Notes what about a pseudo
Perl program like this?

general init stuff
trap sigalarm {
        code to find the best cache;
        $best = "bestcache";
        set alarm for x seconds

        while (<>) {
                    do pre-redirection
                    redirect sticking in $best

set off sigalarm now

        I've not really played with the redirector part of squid much so
my understanding may be really off balance. If the idea is sound, however,
I could whip up the shell code, leaving the "which host is best" part as
just a function. This might provide a new avenue of usage for Squid :)

- Daniel R. <> []
Received on Fri May 16 1997 - 13:36:14 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:35:12 MST