[squid-users] Switch cache peer Parent server for every 30 minutes

Alex Rousskov rousskov at measurement-factory.com
Wed Jun 10 13:42:06 UTC 2020


On 6/10/20 6:09 AM, Prem Chand wrote:

> My squid cache peer has 3 parent IP’s configured. I need to send HTTPS
> requests to the first parent IP for 30 minutes and after to the 2nd
> parent IP for 30 minutes and then to 3rd IP for 30 minutes and this
> switching needs to happen continuously .Could you please let us know how I
> can achieve this?

If you are OK with hard-coded usage time slots for each peer, then I
would use two[1] "time" ACLs and cache_peer_access rules. Look for
"aclname time" in squid.conf.documented. You will have to generate a
list of (24*2/3=16) staggered time slots for each of the two ACLs, but
it should work. This may be the simplest solution.

[1] You need two ACLs for three peers because the third peer should get
the requests that the first two peers were not allowed to get.

----

With a modern Squid, you could also implement this using a more flexible
(and more expensive, on several layers!) architecture with two ACLs:

1. An external ACL that returns the right cache peer name to use via a
keyword=value annotation API. This always-matching ACL should be
attached to http_access or a similar directive that supports slow ACLs.
Its goal is to annotate the request. You will need to write a
script/program that will compute the right annotations based on time or
some other factors. This is where the flexibility of this solution is
coming from.

2. A "note" ACL attached to cache_peer_access directives, allowing
access to peer X if the external ACL in item 1 returned
use_cache_peer_=X. The "note" ACL is a fast ACL and, hence, can be
reliably used with cache_peer_access.

If you already have another external ACL, you may be able to piggyback
annotations in item 1 to whatever that ACL is already doing.

For more information, search for "keyword=value" and "acl aclname note"
in your squid.conf.documented and see
https://wiki.squid-cache.org/Features/AddonHelpers#Access_Control_.28ACL.29


HTH,

Alex.


More information about the squid-users mailing list