Online Book Reader

Home Category

Squid_ The Definitive Guide - Duane Wessels [102]

By Root 2135 0

If the reply is a miss, and it is from a sibling, it is ignored.

Squid doesn't immediately act on ICP/HTCP misses from parents. Instead, it remembers which parents meet the following criteria: The closest-parent miss

If the reply includes a netdb RTT measurement, Squid remembers the parent that has the least RTT to the origin server.

The first-parent miss

Squid remembers the parent that had the first reply. In other words, the parent with least RTT to your cache. Two cache_peer options affect this part of the algorithm: weight= N and closest-only.

The weight= N option makes a parent closer than it really is. When calculating RTTs, Squid divides the actual RTT by this artificial weight. Thus you can give higher preference to certain parents by increasing their weight value.

The closest-only option disables the first-parent miss feature for a neighbor cache. In other words, Squid selects a parent (based on ICP/HTCP miss replies) only if that parent is the closest to the origin server.

If Squid receives the expected number of replies (all misses), or if the timeout occurs, it selects the closest-parent miss neighbor if set. Otherwise, it selects the first-parent miss neighbor if set.

Squid may not receive any ICP/HTCP replies from parent caches, either because they weren't queried or because the network dropped some packets. In this case, Squid relies on the secondary parent (or direct) selection algorithm described in the next section.

If the ICP/HTCP query timeout occurs before receiving the expected number of replies, Squid prepends the string TIMEOUT_ to the result code in access.log.

Step 3: Secondary Parent Selection

This step is a little tricky. Remember that if the direct flag is DIRECT_YES, Squid never executes this step. If the flag is DIRECT_NO, Squid calls the getSomeParent( ) function (described subsequently) to select a backup parent, in case Step 2 failed to select one. Following that, Squid adds to the list all parents it believes are alive. Thus, it tries all possible parent caches before returning an error message to the user.

In the case of DIRECT_MAYBE, Squid adds both a parent cache, and the origin server. The order, however, depends on the prefer_direct setting. If prefer_direct is enabled, Squid inserts the origin server into the list first. Next, Squid calls getSomeParent( ) if the request is hierarchical or if the nonhierarchical_direct directive is disabled. Finally, Squid adds the origin server last if prefer_direct is disabled.

The getSomeParent( ) function selects one of the parents based on the following criteria. In each case, the parent must be alive and allowed to handle the request according to the cache_peer_access and cache_peer_domain rules:

The first parent with the default cache_peer option

The parent with the round-robin cache_peer option that has the lowest request count

The first parent that is known to be alive

Retrying

Occasionally, Squid's attempt to forward a request to an origin server or neighbor may fail for one reason or another. This is why Squid creates a list of appropriate next-hop locations during the neighbor selection procedure. When one of the following types of errors occurs, Squid can retry the request at the next server in the list:

Network congestion or other errors can cause a "connection timeout."

The origin server or neighbor cache may be temporarily unavailable, causing a "connection refused" error.

A sibling may return a 504 (Gateway Timeout) error if the request would cause a cache miss.

A neighbor may return an "access denied" error message if the two caches have a mismatch in access control policies.

A read error may occur on an established connection before Squid reads the HTTP message body.

There may be race conditions with persistent connections.

Squid's algorithm for retrying failed requests is relatively aggressive. It is better for Squid to keep trying (causing some extra delay), rather than return an error to the user.

How Do I ...

New Squid users often ask the same, or similar, questions about

Return Main Page Previous Page Next Page

®Online Book Reader