Link to home
Start Free TrialLog in
Avatar of ddiazp
ddiazpFlag for Canada

asked on

Load balancing Squid and Web Servers with Squid

Greetings,

We have 2 squid servers (each one with a public IP) and 2 web servers.


We have 2 DNS records published so users will load balance across the 2 squid servers, but how do I load balance the squid servers across the 2 web servers?

for example, users go to www.test.com.

they arrive at either cache1 or cache2.

How do I tell cache1 to load balance between web1 and web2? same with cache2?

We are doing this through multiple DNS entries which our local DNS server respond with both web server IP addresses; but what happens if one web server goes down?

How can I tell squid to load balance across multiple web servers for the same domain and if one of the web servers go down to easily take it of the configuration? We have implemented round robin DNS but the problem is that if a server goes down DNS won't know about it and even if we remove it from DNS the cache server will have that IP address in dns cache


What's the better way to do this?
ASKER CERTIFIED SOLUTION
Avatar of mooodiecr
mooodiecr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mooodiecr
mooodiecr

Avatar of ddiazp

ASKER

We already have something similar:


http_port 80 accel defaultsite=www.test.com vhost
cache_peer www1.test.com parent 80 0 no-query no-digest originserver name=cache_www default

where www1.test.com is our other cache server. Is this wrong?



Or do we need to remove:

cache_peer www1.test.com parent 80 0 no-query no-digest originserver name=cache_www default

and add:

cache_peer web1.test.com parent 80 0 no-query no-digest originserver name=cache_www default
cache_peer web2.test.com parent 80 0 no-query no-digest originserver name=cache_www default
That is correct:
"
Or do we need to remove:

cache_peer www1.test.com parent 80 0 no-query no-digest originserver name=cache_www default

and add:

cache_peer web1.test.com parent 80 0 no-query no-digest originserver name=cache_www default
cache_peer web2.test.com parent 80 0 no-query no-digest originserver name=cache_www default
"

the port and accel entry is the site that is to be used and then there needs to be two separate entries for the load balancing sites.  Just to note the IP address or DNS name can resolve locally if needed.  i.e. web2.test.com can read 127.0.0.1
Avatar of ddiazp

ASKER

Awesome, one last question.

What will Squid do in the event that one of the webX.test.com is down or cannot contact it?
Squid tracks the reachability status of its neighbour caches. When using ICP, or any other protocol you choose, Squid marks a neighbour as down when the neighbour fails to reply to 20 consecutive ICP queries. As soon as a reply is received again, the neighbour is marked up.

In addition to ICP, Squid also monitors TCP connections. When a TCP connection to a neighbour fails, Squid marks the neighbour down and begins a process to periodically (every 80 seconds) retry a diagnostic TCP connection. When the diagnostic connection succeeds, the neighbour is marked up.

So, in order for Squid to consider a neighbour cache as up, these two conditions must be true:

   1. The last TCP connection must have been successful.
   2. There must be fewer than 20 consecutive unacknowledged ICP queries.
Avatar of ddiazp

ASKER

You say cache neighbors. Are these the actual webservers? We'll implement this and give it a shot.

Thanks
In your scenario it would be whatever site is being served/cached so yes.
Avatar of ddiazp

ASKER

This worked, forgot about closing this ages ago!