Re:Cache Concurrency Control
by jwahba on Thursday May 30, 2019 @09:07PM
(#20057470)
For patterns like this I like to reach for request coalescing. Here's an example of a package that does it in the golang standard lib https://godoc.org/golang.org/x/sync/singleflight
[ Parent
| on HN ]
Big fan of request coalescing, was introduced to it by Varnish. Really helps when a cache entry drops.
I believe what the article did is called a "grace period".
Are there any open implementations of distributed request coalescing? Pretty easy to do using a service proxy, but what about something like a Raft cluster?
I'm curious if assigning a random value from an acceptable range for the expiry time is a common approach. I assume that wouldn't work for all cases, but might spread the avalanche for some.
Google searches on this topic (random expiry to mitigate an avalanche cache refresh) turn up very little.
It is very common and often referred to as jitter.
A variation, called scaled ttl, was nicely discussed in this video. https://www.youtube.com/watch?v=kxMKnx__uso