Cache miss stampedes

Chris Hondl chris at imvu.com
Wed Jul 25 15:49:31 UTC 2007


We've hit this scenario several times over the past year on different
queries - typically slow queries (5-10 seconds) on frequently accessed web
pages.  We usually cache these for 6 hours or longer.

We handle this with a probabilistic timeout implemented in our application.
We store a timestamp and expiration time serialized as part of the value set
to memcache.  The last minute or so before the key expires we randomly run
the query and set the value to memcache with a new expiry.  The probability
ramps up from 0% to 100% over the last minute or so.

In two places we use a different algorithm.  We set no expiry on the value,
but on every get we have a 1 in N chance of refreshing the value.  We tune N
so that the value gets refreshed approximately once every 5 minutes.
Annoying part about this is as our traffic grows we have to change N to keep
the expected interval constant.

Chris

-- 
http://avatars.imvu.com/chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/memcached/attachments/20070725/6e3875ab/attachment.htm


More information about the memcached mailing list