Squid on windows loadbalancing only to one server
Posted
by
Martin L.
on Server Fault
See other posts from Server Fault
or by Martin L.
Published on 2012-10-19T10:57:26Z
Indexed on
2012/10/19
11:06 UTC
Read the original article
Hit count: 245
After thousands of googles and trying days i cant get the load balancer/failover in squid on windows to work. Iam using squid 2.7. My webservers are 2 single NIC lighttpd and one dual nic lighttpd. server1 in this example is running squid on port 80 and lighttpd on port 8080 (just to test)
Requirements:
- All 3 webservers running lighttpd should be balanced
- two option for load balancing:
- Best would be if server1 is busy server2 takes over, if server2 is
busy server3 takes over, etc.. - Round robin style evenly distributed load. Eg server1 takes first call, server2 second etc.. All requests should be treated the same way (no url rewriting or so on)
- Best would be if server1 is busy server2 takes over, if server2 is
- Sent host headers have to be redirected to every server as http host header, speaking of "server1", "server1.company.internal" and "10.211.1.1".
My approach:
acl all src all
acl manager proto cache_object
http_port 80 accel defaultsite=server1.company.internal vhost
#reverse proxy entries
cache_peer 10.211.2.1 parent 8080 0 no-query originserver round-robin login=PASS name=server1_nic1
cache_peer 10.211.1.2 parent 80 0 no-query originserver round-robin login=PASS name=server2_nic1
cache_peer 10.211.2.3 parent 8080 0 no-query originserver round-robin login=PASS name=server3_nic1
cache_peer 10.211.2.4 parent 8080 0 no-query originserver round-robin login=PASS name=server3_nic2
#decl of names of squid host
acl registered_name_hostdomain dstdomain server1.company.internal
acl registered_name_host dstdomain server1
#ip of squid host
acl registered_name_ip dstdomain 10.211.2.1
# access: redirects the correct squid hostname
http_access allow registered_name_hostdomain
http_access allow registered_name_host
http_access allow registered_name_ip
http_access deny all
cache_peer_access server1_nic1 allow registered_name_hostdomain
cache_peer_access server1_nic1 allow registered_name_host
cache_peer_access server1_nic1 allow registered_name_ip
cache_peer_access server2_nic1 allow registered_name_hostdomain
cache_peer_access server2_nic1 allow registered_name_host
cache_peer_access server2_nic1 allow registered_name_ip
cache_peer_access server3_nic1 allow registered_name_hostdomain
cache_peer_access server3_nic1 allow registered_name_host
cache_peer_access server3_nic1 allow registered_name_ip
cache_peer_access server3_nic2 allow registered_name_hostdomain
cache_peer_access server3_nic2 allow registered_name_host
cache_peer_access server3_nic2 allow registered_name_ip
cache_peer_access server1_nic1 deny all
cache_peer_access server2_nic1 deny all
cache_peer_access server3_nic1 deny all
cache_peer_access server3_nic2 deny all
never_direct allow all
Problems:
- Load balancer does not load balance other than to first server. Only if the first server is killed in any way the second will take over. I have seen the others working at some point, but definitely not as the intended load balancing described above.
- If the cache_peer_access is not defined sometimes the wrong hostname is sent to the backend webserver and this always depends on the defaultsite= parameter. Probably because the host header on the request to squid is not set and its replaced by defaultsite. Leaving out defaultsite didnt solve the problem. The only workaround i found for this is the current approach with cache_peer_access.
Questions:
- Does the cache_peer_access influence the round-robin?
- Is there a better workaround to pass the host header to the backed webservers?
- Which parameters do increase the speed of load balancing or does anyone have a better approach?
-Martin
© Server Fault or respective owner