Tuning Cache Efficiency
Once you've stabilized Squid, you can then proceed to fine-tune its operating
efficiency. The config file contains over 100 tuning knobs. Among other
things, you can:
modify listening ports, IP addresses, hostnames, and connect, select,
request, and ident timeouts
modify outgoing ports to spread response handling across multiple
interfaces
specify ICP ports, neighbor selection criteria (including weight and
TTL), and cache digests
set cache swap high and low water marks for cache object replacement
limit the largest object size or prevent caching based on URL substrings
determine the location, size, and index levels for cache storage configure
the size and refresh behavior for the IP and FQDN (DNS) caches
enable and configure memory pools to increase speed
enable and configure delay pools to constrain bandwidth
set maximum HTTP request and reply body and header sizes to protect
against DOS attacks
define min / max lifetimes for objects without TTL, identified by
URL regular expression
choose a replacement policy (see below)
Earlier versions of Squid had a single self-explanatory replacement policy:
Least Recently Used (LRU). In version 2.3, you can also choose Greedy-Dual
Size Frequency (GDSF) or Least Frequently Used with Dynamic Aging (LFUDA).
GDSF gives priority to smaller objects that have a better chance of getting
hit. LFUDA is more like LRU, but employs a dynamic aging mechanism that
is said to be more efficient than recent usage. Generally, GDSF produces
a higher hit rate, while LFUDA reduces WAN bandwidth use. For further details,
follow the URLs supplied in squid.conf.
Squid can't provide the patented adaptive or predictive refresh methods
used by some commercial caching products, and doesn't include the ability
to preload specified high-utilization sites. However, it is quite simple
to write a script that uses wget to download
sites, invoked on a scheduled basis by cron.
You'll find a tuning tips to increase hit rate, improve response time,
and optimize cache performance in the Squid FAQ. The Cache Manager offers
instantaneous, tabular stats. General
Runtime Info summarizes HTTP, ICP, and DNS request rates, hit ratios,
median service times, mean object size, CPU, memory, swap, and file descriptor
usage.
Many stats are summarized over
the past five minutes and hour. Further detail is provided for memory
and cache utilization, DNS (IP and FQDN) cache content and stats,
store directory stats (right), and objects that are in memory,
in transit, or being swapped out. Peer selection algorithms, stats,
and digest info monitor hierarchy performance. Header
and refresh stats, traffic counters, and server-side histograms show
how hard Squid is working to retrieve content.
The client list (left),
client-side active requests, persistent connection utilization, and
authenticator stats summarize request activity. It takes time to find
what you're looking for and get comfortable with interpreting the
voluminous data presented here.