7

I'm using varnish with -s malloc,1G"

It's currently 98% full. Once it completely full what will happen?

Will it purge?

Maybe purge old images/pages?

Or better yet purge the files with least amount of hits?

danronmoon
  • 3,814
  • 5
  • 34
  • 56
Hayden
  • 361
  • 4
  • 18

1 Answers1

11

It looks like Varnish uses a LRU (least recently used) strategy to remove items from cache when the cache becomes full with things whose TTL (time to live) has not expired (so first remove things whose TTL is expired, if the cache is still full remove things least recently accessed).

See

https://www.varnish-cache.org/trac/wiki/ArchitectureLRU

Note you can watch the n_lru_nuked counter to see the rate at which things are being flushed from the cache due to LRU.

Eric J.
  • 147,927
  • 63
  • 340
  • 553
  • I have a lot of objects with a very low hit rate (approx 0.5). I'm using IPB forum software and (http://community.invisionpower.com/topic/328398-unbelievable-results-with-varnish/) and its the best hitrate based on the suggested vcls. In which case if I lower my cache to 512MB that will make my hit rate worst correct? – Hayden Nov 04 '11 at 23:19
  • @hydn: The smaller the cache, the lower your hit rate will be... up to a point. Think of it this way... if your cache is just as large as your database, you will have a 100% hit rate (except for reading in new / updated records the first time). If your cache is 0MB, you will have a 0% hit rate... no room in the cache so always goes to the database. There's usually a "sweet spot" where a certain amount of RAM will give you say 80% hit rate and you have to add a disproportionate amount of RAM for each extra %. On the other hand, if you have UNUSED RAM, might as well use it for cache. – Eric J. Nov 26 '11 at 18:05