Search code examples
azureredisazure-redis-cache

Redis caches - when can large evictions be triggered?


We have a Redis Cache on Azure Standard 2.5gb. We observe the following behaviour:

enter image description here

Every now and then, we observe large drops in memory usage. It appears that lots of resources are being evicted.

Things to note:

  • Eviction policy is LRU
  • Available cache size is 2.5gb
  • No application code that would evict such large amounts of memory (largest objects are ~80kb and most are significantly smaller)
  • Observed memory drops represent tens of thousands of keys
  • We seldom use explicit expiry dates on cached objects, and when we do they are always < 1 hour.

My question is, apart from application logic explicitly evicting keys are there any other circumstances Redis would evict large amounts of keys?


Solution

  • The memory cleanup may not represent evictions.

    You say "it appears" that lots of resources are being evicted, but if you are just relying on the reclaimed memory for that appearance, you may be chasing ghosts. Have you checked how this graph overlays with the Total Keys metric available in the Azure Portal? Overlaying the two series should allow you to see whether or not the memory reclamation really is due to eviction or if it's due to another process like Azure perhaps calling MEMORY PURGE periodically on the cache instance to clean up dirty pages?