Avoiding Thundering Herd in Memcached | newspaint
This article might also be interpreted as "locking shared resources using memcache".
A common problem with sites that use memcached is the worry that when memcached is restarted and the cache is empty then a highly-scaled application will hit the cold cache and find it empty and then many threads will proceed to all simultaneously make heavy computed lookups (typically in a database) bringing the whole site to a halt. This is called the "Thundering Herd" problem.
There are two worries about "Thundering Herd". The first, and considered by this article, is where you may have a complex and expensive database query that is used to calculate a cached value; you don't want 100 users simultaneously trying to access this value soon after you start your application resulting in that complex database query being executed 100 times when a single execution will do the job. Better to wait for that single query to complete, populate the cache, then all the other users can get the response near instantly afterwards. The second worry is that an empty cache will need filling from many different types of queries – this article does not help with that problem – but then pre-filling a cache could be difficult (if which needed cached values are not determinable ahead of time) and will take time in such a situation nonetheless.
Read full article from Avoiding Thundering Herd in Memcached | newspaint
No comments:
Post a Comment