MintCache (simple version)

MintCache is a caching scheme Disqus has recently implemented. We posted Disqus’ implementation of MintCache for others to use.

From the original MintCache posting:

The purpose of this caching scheme is to avoid the dog-pile effect. Dog-piling is what normally happens when your data for the cache takes more time to generate than your server is answering requests per second. In other words if your data takes 5 seconds to generate and you are serving 10 requests per second, then when the data expires the normal cache schemes will spawn 50 attempts a regenerating the data before the first request completes. The increased load from the 49 redundant processes may further increase the time it takes to generate the data. If this happens then you are well on your way into a death spiral

MintCache works to prevent this scenario by using memcached to to keep track of not just an expiration date, but also a stale date The first client to request data past the stale date is asked to refresh the data, while subsequent requests are given the stale but not-yet-expired data as if it were fresh, with the undertanding that it will get refreshed in a ‘reasonable’ amount of time by that initial request.

Link: MintCache (simple version)

View Comments

Daniel on June 11th 2008 in Django, Python, disqus

  • Have always had problem with caching with my hosting account at GoDaddy especially when implemented with Wordpress which is what I use. Was thinking of checking it out myself, but never got around to it.
  • ryanlow
    Great explanation on what are you doing to speed up the process. I didn't know that without mint caching the system will be greatly slow down due to dog-piling. A great way to solve the issue. However, is there other ways as well?
  • My concern with disqus is that they hold your data!. Data ownership is really a risk, with the current economic climate are you comfortable with the fact that your data is in tyhe hands of others?. We all need to ensure we manage our business risks during these difficult times.
  • george
    This is new version. The main purpose of this version is to avoid the dog-pile effect.
    ______________________________________________
    george
    Addiction Recovery Massachusetts
  • Have always had problem with caching with my hosting account at GoDaddy especially when implemented with Wordpress which is what I use. Was thinking of checking it out myself, but never got around to it.
  • skabber
    I would be interested to know why you use this (simple version) instead of the original MintCache.
  • We found the original hard to understand. This version is also decoupled from the cache backend that you use.
  • I'm the author of the original mint cache and completely agree that this implementation is a very nice improvement. ( the original was written under duress! ) Kudos, guys!
  • Thanks, Glenn! Sharing code is a beautiful thing. In case you're interested, one other feature we are considering adding is a "delete" method that merely lowers the timeout on the cached value (instead of truly deleting it), thereby triggering the mint refresh. That way one could avoid the dogpile effect when manually invalidating.
blog comments powered by Disqus