2

Is there any way to configure Squid to choose a peer cache based on the latency in communication to the http port on the destination webserver?

For example, let's say we have two Squid caches - server 'A' in the USA and server 'B' in China. We know accessing any websites outside China means that it adds about 200-250ms round trip time to the packet due to cables crossing the Pacific. I would like Squid on server 'A' to probe that and only forward the request on to server 'B' if the latency is above a certain threshold. Otherwise, it accesses the webserver directly.

If this behaviour must be programmed into Squid, do you have any suggestions on where to plug it in to the architecture?

2 Answers2

2

It looks like what you need is configured with the cache_peer directive. Here's an example right from the docs:

cache_peer cache.domain.example parent 3128 3130 default

Instead of or in addition to "default" in the last position, you can specify "weight" and "no-query".

The "no-query" option tells squid to send ICP requests first, to all configured caches. The quickest cache to respond is where the HTTP request will be directed.

The "weight" flag will tell squid that when more than one configured cache has an object, to use the quickest responding cache to fetch that object.

Full details of these options are in the documentation, but this should be enough to get you going.

Rob F
  • 396
  • 1
  • 7
1

If I understood you correctly, I don't think it makes much sense the way you put it.

Be aware that in order to measure the latency you would need to send at least a couple of probes, so it will take practically as much time as fetching the object itself.

Aleksandar Ivanisevic
  • 3,377
  • 21
  • 24