3 ms·
Probabilistic Cache Recompute to Defeat Cache Stampedes
- areyohrahul 3y agoLearn about the cache stampede problem and how you can tackle it using a probabilistic cache recompute strategy.
- csense 3y agoArticle says "Math.log(new Random().nextDouble()) generates a random number between -1 (exclusive) and 0", this seems a mistake. Actually this gives you any negative number. If you negate the output (i.e. -log(rand())) you get an exponential distribution, According to the linked paper, an exponential distribution is actually optimal. (The paper defines "expiration gap" to be how much earlier than normal a key expires. The paper proves that, for any fixed allowance of expected expiration gap, an exponential distribution minimizes the expected stampede size.)
- areyohrahul 3y agoThanks for pointing this out. I've corrected this in the article now.