Re: [squid-users] Re: Help me About Squid

From: Kevin <[email protected]>
Date: Mon, 21 Feb 2005 16:28:15 -0600

On Mon, 21 Feb 2005 21:00:37 -0000, Ric Lonsdale
<bikerric@blueyonder.co.uk> wrote:
> Following the thread above, I have 4Gb RAM, 11Gb for the cache and 5Gb for
> swap.

You'll want to keep an eye on swap usage and paging activity (vmstat).
Some operating systems (Solaris) will inherently always have swap in use,
and tools like "top" will always show a few megs "swap in use", other
systems (OpenBSD) will show 0K swap "used" until main memory runs low.

Additionally, Solaris is inherently designed to take advantage of all
available memory, RAM that isn't allocated to any process will be occupied
by file cache, and Solaris will go out of it's way to swap "idle" pages out of
main memory to make more space available for applications and low-level
OS caches (file data, inodes, etc).

> I've set cache_mem to 2Gb as I too thought that the higher this field was
> set to, the better the performance would be, as Squid would be able to store
> more in memory, therfore requiring less retrievals from the disk.

What is tuned by cache_mem is how much RAM (or swap, in degenerate
cases) is *explicitly* allocated to squid for caching objects in memory.
This is distinct from the memory used for the squid runtime and the
metadata "overhead" memory dynamically allocated to the process --
TMK there is no way to control or limit the RAM squid uses for metadata.

IMHO, you always want to set cache_mem low enough that the system
doesn't run low on free pages and start to swap unnecessarily. On a
dedicated squid cache machine (no other services running), you don't
want the OS to ever be forced to move "live" pages from main memory
to disk and back again, as this significantly degrades performance, much
more than if squid were forced to go to disk to retrieve cached content.

> Users are complaining about internet speed and I have been blaming WAN
> bandwidth from their location up to the Squid servers and also the ISP link.
> I'm now a bit worried that I've misinterpreted previous mailings on sizing
> of cache_mem.
> Can you clarify, as my swap is currently using 1Gb as well as all the RAM.
> If I set it to 8Mb, are you saying that Squid will use the rest of my 4Gb
> RAM as it sees fit?

Not exactly.
If you set cache_mem to 8 megabytes, squid will only keep 8 megs worth of
objects in memory, plus consume some additional RAM due to metadata,
ipcache/fqdncache, and other overhead.

However the OS will "use the rest of my 4Gb RAM is it sees fit". How much
of the "free" memory will be allocated towards filesystem metadata, how much
to caching disk files (including frequently accessed squid cache objects) and
how much to other uses is entirely determined by your OS.

> If so why have this setting?
> I'm missing the point here I'm sure, so please advise.

The idea behind cache_mem is that you don't know for sure how your kernel
is going to choose to make use of "free" system RAM, so you instead choose
to have squid itself explicitly store small frequently accessed objects in
memory (or swap, if things go sour).

I haven't done any benchmarking, but I'd venture that even on an OS such as
Solaris where "free" memory is actually used as file cache, squid is still
significantly more efficient when returning objects directly from cache_mem
rather than using OS system calls to read (OS cached) files from disk.

Kevin Kadow
Received on Mon Feb 21 2005 - 15:28:21 MST

This archive was generated by hypermail pre-2.1.9 : Tue Mar 01 2005 - 12:00:02 MST