[squid-dev] Developing customized Cache Selection algorithm from Round Robin, Least Load

Alex Rousskov rousskov at measurement-factory.com
Thu Aug 20 04:15:53 UTC 2015


On 08/19/2015 05:03 AM, Du, Hongfei wrote:

> We are in an attempt to extend Squid Cache selection algorithm to
> develop a solution for controlled storage of subscriber’s content in
> Squid Caches, and thereafter apply access rule on these contents, a few
> questions to start with:
> 
> ·        As we probably has to rewrite new algorithm and recompile it,
> so does anyone know where(or which file) is the existing Round Robin or
> Least Load algorithm defined in source codes?

Search for the storeDirSelectSwapDir variable in src/store_dir.cc. To
learn more about customizing cache dir selection code, run:

  $ bzr grep Config.store_dir_select_algorithm

or an equivalent search command.


> ·        Is there straight forward method to tell/instruct squid to
> store content(e.g. an URL)  from network in a predefined specific disk
> folder rather than using the selection algorithm itself?

You can use cache_dir min-size and max-size options to control cache_dir
selection to some extent.

You can use the "cache" directive in squid.conf to control what gets
stored and served from the cache. This directive accepts Squid ACLs, so
it can be applied to specific URLs, but it cannot allow or prohibit
individual cache_dir usage.

I am not aware of any other configurable interface at the individual URL
level. There is no configurable mapping of URLs/StoreIDs to cache_dirs
(and beyond). The storeDirSelectSwapDir variable mentioned above points
to one of the two functions that do the mapping (selected at
configuration time based on store_dir_select_algorithm in squid.conf).


The details of the cache_dir selection code are rather ugly, with
several half-broken interfaces augmented by weird storage
module-dependent implementations. Do not expect a smooth sailing.


Good luck,

Alex.



More information about the squid-dev mailing list