Solved

Load balancing Squid and Web Servers with Squid

Posted on 2010-09-23
9
683 Views
Last Modified: 2012-06-27
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?
0
Comment
Question by:ddiazp
  • 5
  • 4
9 Comments
 
LVL 5

Accepted Solution

by:
mooodiecr earned 500 total points
ID: 33748873
Squid has a similar round -robin technique you can try.  We use this very successfully for an extremely busy website.  In the squid configuration file add:

http_port 1.2.3.4.:80 defaultsite=www.thefraggle.com vhost
cache_peer 1.2.3.5 parent 80 0 no-query originserver round-robin
cache_peer 1.2.3.6 parent 80 0 no-query originserver round-robin

This can be placed at the very top of the squid config file.
0
 
LVL 5

Expert Comment

by:mooodiecr
ID: 33748896
0
 
LVL 10

Author Comment

by:ddiazp
ID: 33749031
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
0
 
LVL 5

Expert Comment

by:mooodiecr
ID: 33749290
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
0
Save on storage to protect fatherhood memories

You're the dad who has everything. This Father's Day, make sure your family memories are protected. My Passport Ultra has automatic backup and password protection to keep your cherished photos and videos safe. With up to 3TB, you have plenty of room to hold the adventures ahead.

 
LVL 10

Author Comment

by:ddiazp
ID: 33749365
Awesome, one last question.

What will Squid do in the event that one of the webX.test.com is down or cannot contact it?
0
 
LVL 5

Expert Comment

by:mooodiecr
ID: 33754927
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.
0
 
LVL 10

Author Comment

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

Thanks
0
 
LVL 5

Expert Comment

by:mooodiecr
ID: 33756140
In your scenario it would be whatever site is being served/cached so yes.
0
 
LVL 10

Author Closing Comment

by:ddiazp
ID: 34403583
This worked, forgot about closing this ages ago!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FTP output from Wireshak 6 76
Guest VLAN not syncing email 13 32
Web Reply Form - PHP with Upload 4 56
F5 SSL Sticky Load Balancing Question 3 28
I will assume you are running a non-server version of some sort of Windows throughout this article. There are many flavors of Windows since Windows Server 2000 - 2008, XP Home & Pro, Vista Home & Pro, and Windows 7 Starter, Home, Pro, Ultimate, etc.…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now