Cache miss stampedes
Steven Grimm
sgrimm at facebook.com
Thu Jul 26 08:13:13 UTC 2007
I admit I'm a bit baffled by this discussion (and I also admit I have
only been skimming it, so this might be a retread.) It seems like one of
two situations should be true:
1. The underlying data has not changed. The cache is therefore still
correct.
2. The underlying data has changed, and the cache is now stale.
In the first case, just don't set an expiration time and you're done,
yes? Since the item is frequently hit (hence the stampedes) it will
never get LRUed out.
In the second case, why are you waiting around for some unknown amount
of time to pass -- and for some client to get an actual cache miss --
before refreshing the cache? If you have a few hot keys that change
often but for whatever reason you can't invalidate / update the cache at
the time the underlying data gets updated, then another approach is to
have some background task periodically updating the hot items to their
current values. Again, you don't let the item expire in this scenario;
it just gets updated every once in a while. This way nobody has to deal
with a cache miss, and the values still stay as current as you want them
to (adjust the frequency of your background task's updates to taste)
with no stampedes.
What am I missing?
-Steve
More information about the memcached
mailing list