Re: Load Balancing

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Tue, 11 Apr 2000 22:12:57 +0200

John Reilly wrote:

> I have a small problem here - I am trying to use squid to act
> as a load balancer to a number of http servers, i.e. www.blah.com
> is squid which does a redirect to www1.blah.com or www2.blah.com

If you doesn't need "true" load-balancing but round-robin is fine, then
create a DNS/host record listing all the IP addresses and accelerate to
this DNS/host entry.

If you need "true" load balancing then you need a redirector which knows
how to make the distribution.

> I setup 2 virtual interfaces on www which the redirector script re-writes IP addresses to www1 and www2 hostnames in the URLs.
>
> setting are:
> httpd_accel_host virtual
> httpd_accel_port 80

This is not for load balancing. It is for accelerating several IP-based
servers in case there are old clients not sending the Host: header.

What this can do for you is to send any request arriwing on IP
192.168.0.1 to www1.example.com and request arriwing on IP 192.168.0.2
to www2.example.com.

If you only have one single "server" (visible host name un the URL) then
httpd_accel_host virtual" is defenitely not what you want.

Try this setup:

1. Build Squid using dnsserver
(./configure --disable-internal-dns for Squid-2.3, Default for Squid-2.2
and earlier)

2. Add all the "real" IP addresses for www.example.com to your
/etc/hosts file
192.168.0.1 www.example.com
192.168.0.2 www.example.com

3. Change /etc/nsswitch.conf to prefer files over DNS
hosts: files dns

4. Configure squid with
httpd_accel_host www.example.com
httpd_accel_port 80

This will distribute the requests using round-robin on the
www.example.com IP addresses listed in /etc/hosts on the proxy server.

If you need another load distribution than round-robin, then you must
use a redirector process which implements this distribution.

--
Henrik Nordstrom
Squid hacker
Received on Tue Apr 11 2000 - 15:17:39 MDT

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