Re:How not to structure database-backed web apps: performanc...
by blattimwind on Thursday June 28, 2018 @10:51AM
(#17417292)
The easiest workaround is to acquire a lock (e.g. redis redlock) before starting to refresh the cache. That way only one process will perform expensive_calculation(). A good caching library will generally do some variation on this for you.
For larger, more complex scenarios the techniques mentioned by GGP above work well, i.e. not doing expensive_calculation() in your app process at all.
The issue has a bunch of names, I know at least three: cache stampede, thundering herd and dogpile effect.
For larger, more complex scenarios the techniques mentioned by GGP above work well, i.e. not doing expensive_calculation() in your app process at all.
The issue has a bunch of names, I know at least three: cache stampede, thundering herd and dogpile effect.