Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.