Re: [squid-users] cache_replacement_policy ==> Clarification Please & Thank You

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Sat, 31 Aug 2013 16:19:17 +1200

On 31/08/2013 11:25 a.m., HillTopsGM wrote:
> I have read through the notes in the default config file notes on the topic.
> Here's the notes from the file:
>
>
>> # TAG: cache_replacement_policy
>> # The cache replacement policy parameter determines which
>> # objects are evicted (replaced) when disk space is needed.
>> #
>> # lru : Squid's original list based LRU policy
>> # heap GDSF : Greedy-Dual Size Frequency
>> # heap LFUDA: Least Frequently Used with Dynamic Aging
>> # heap LRU : LRU policy implemented using a heap
>> #
>> # Applies to any cache_dir lines listed below this.
>> #
>> # The LRU policies keeps recently referenced objects.
>> #
>> # The heap GDSF policy optimizes object hit rate by keeping smaller
>> # popular objects in cache so it has a better chance of getting a
>> # hit. It achieves a lower byte hit rate than LFUDA though since
>> # it evicts larger (possibly popular) objects.
>> #
>> # The heap LFUDA policy keeps popular objects in cache regardless of
>> # their size and thus optimizes byte hit rate at the expense of
>> # hit rate since one large, popular object will prevent many
>> # smaller, slightly less popular objects from being cached.
>> #
>> # Both policies utilize a dynamic aging mechanism that prevents
>> # cache pollution that can otherwise occur with frequency-based
>> # replacement policies.
>> #
>> # NOTE: if using the LFUDA replacement policy you should increase
>> # the value of maximum_object_size above its default of 4096 KB to
>> # to maximize the potential byte hit rate improvement of LFUDA.
>> #
>> # For more information about the GDSF and LFUDA cache replacement
>> # policies see http://www.hpl.hp.com/techreports/1999/HPL-1999-69.html
>> # and http://fog.hpl.external.hp.com/techreports/98/HPL-98-173.html.
>> #Default:
>> # cache_replacement_policy lru
>
> I really don't understand the difference between:
> cache_replacement_policy lru
> &
> cache_replacement_policy heap LFUDA
>
> *Question 1*
> In the description above under heap LFUDA above, is it implying that the
> default lru setting somehow takes into account the size of the files as
> well?

No. "heap" and "lru" algorithms are fully independent.

LRU algorithm deals strictly with _time_/age property of objects.
HEAP algorithms deal with both time/age and size property of objects.

>
>> . . . heap LFUDA policy keeps popular objects in cache regardless of their
>> size . . . .
> *Question 2*
> Does lru just dump the largest files first?

No it walks over a linked-list dumping the oldest each time.
Any time a URL is requested its object is bumped to the front of the
list and becomes the youngest.

> As I am more interested in caching larger files, (like windows updates), and
> after reading this submission
> <http://squid-web-proxy-cache.1019090.n4.nabble.com/recommended-memory-cache-replacement-policy-tp1039362p1039368.html>
>
> I was thinking of using this setup:
>
>
>> cache_replacement_policy heap LFUDA
>> cache_dir ufs /var/spool/squid3_cache_1 51200 16 256
>> cache_dir ufs /var/spool/squid3_cache_2 51200 16 256
>> cache_dir ufs /var/spool/squid3_cache_3 51200 16 256
>> cache_dir ufs /var/spool/squid3_cache_4 51200 16 256
>>
>> memory_replacement_policy heap GSDF
>> maximum_object_size_in_memory 2048 KB
> *Question 3*
> Have I placed the replacement policy tags in the correct place - ie. above
> the cache_dir's and maximum_object_size_in_memory?

That should be fine. I'm not aware of any ordering problems with that
directive but your usage there would avoid any if they are present in
the same way as the max-size limit ones.

Amos
Received on Sat Aug 31 2013 - 04:19:27 MDT

This archive was generated by hypermail 2.2.0 : Sat Aug 31 2013 - 12:00:30 MDT