Search squid archive

Fwd: Centralized Squid - design and implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Forwarding, as it may be useful to others.


---------- Forwarded message ----------
From: Kinkie <gkinkie@xxxxxxxxx>
Date: Sun, Nov 16, 2014 at 6:27 PM
Subject: Re:  Centralized Squid - design and implementation
To: alberto <alberto.furia@xxxxxxxxx>


On Sun, Nov 16, 2014 at 5:53 PM, alberto <alberto.furia@xxxxxxxxx> wrote:
> Hi Kinkie
>
> On Sun, Nov 16, 2014 at 5:22 PM, Kinkie <gkinkie@xxxxxxxxx> wrote:
>>
>>    if (dest_hash)
>>      return "PROXY local_proxy1:port; PROXY local_proxy2:port; DIRECT";
>>    return "PROXY local_proxy2:port; PROXY local_proxy1:port; DIRECT"
>> }
>> This will balance by the final digit of the destination IP of the
>> service.
>
>
> With this configuration i can only balance between two nodes in normal
> situation right?
> Whati if i would like to have more nodes balancing the traffic? In case of
> very high load for example.

The hashing is a bit simplicistic. You could do something like (again:
untested):

// if the code works, this is the only tuneable needed. Everything
else self-adjusts
var proxies = ["PROXY proxy1:port1", "PROXY proxy2:port2", "PROXY
proxy3.port3"];

function hash(host, buckets) { // returns a host-dependent integer
between 0 and buckets
  var hostip = dnsResolve(host);
  if (!hostip) // dns resolution failure
    return 0;
  return hostip.slice(hostip.lastIndexOf(".")) % buckets;
}

function FindProxyForURL(url, host) {
  var h = hash(host, proxies.length+1);
  var p = proxies;
  for (var j = 0; j < h; ++j)
    p.unshift(p.pop()); // rotate the "p" array
  return p.join("; ") + "; DIRECT";
}



--
    Francesco


-- 
    Francesco
_______________________________________________
squid-users mailing list
squid-users@xxxxxxxxxxxxxxxxxxxxx
http://lists.squid-cache.org/listinfo/squid-users





[Index of Archives]     [Linux Audio Users]     [Samba]     [Big List of Linux Books]     [Linux USB]     [Yosemite News]

  Powered by Linux