connect icon indicating copy to clipboard operation
connect copied to clipboard

Add random jitter for cache ttl

Open XU-Nuo opened this issue 1 year ago • 1 comments

I am currently using the leveled cache feature to build a 2 level cache with memory and sql cache.

As all my messages comes at a fixed rate, the access to the cache entries are at the same rateas well, resulting all the in memory cache entries expire all toegtehr at the same time and hence sending requests to sql server at the same time.

This create a spike traffic to the database, which is not favorable due to performance issues.

It can be solved to add random jitters for the ttl. I tried to add it in the ttl option in cache processor with random values created in bloblang, but it seems like this option does not work for entries set automatically by the read through mechanism using theleveled cache.

Extend the function of default_ttl can be a solution, we can add an option like default_ttl_jitter to randomize the ttl created by leveled cache.

XU-Nuo avatar Aug 29 '24 09:08 XU-Nuo

Hey @XU-Nuo 👋 That sounds like a reasonable addition. PRs are welcome!

mihaitodor avatar Aug 29 '24 22:08 mihaitodor