Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 675
Quintin Par Avatar asked Mar 25 '12 07:03

Quintin Par


1 Answers

You might have a look at https://github.com/ericflo/django-newcache

like image 171
Brandon Avatar answered Oct 03 '22 21:10

Brandon