Avoiding dog-piling or thundering herd in a memcached expiration scenario

Posted by Quintin Par on Stack Overflow See other posts from Stack Overflow or by Quintin Par
Published on 2012-03-25T07:25:44Z Indexed on 2012/03/25 11:30 UTC
Read the original article Hit count: 244

Filed under:
|
|
|

I have the result of a query that is very expensive. It is the join of several tables and a map reduce job.

This is cached in memcached for 15 minutes. Once the cache expires the queries are obviously run and the cache warmed again.

But at the point of expiration the thundering herd problem issue can happen.

One way to fix this problem, that I do right now is to run a scheduled task that kicks in the 14th minute. But somehow this looks very sub optimal to me.

Another approach I like is nginx’s proxy_cache_use_stale updating; mechanism.

The webserver/machine continues to deliver stale cache while a thread kicks in the moment expiration happens and updates the cache.

Has someone applied this to memcached scenario though I understand this is a client side strategy?

If it benefits, I use Django.

© Stack Overflow or respective owner

Related posts about django

Related posts about algorithm