Such mechanisms also don’t work for functions as a service runtime environments such as Lambda, where containers that run your code are paused and resumed to prevent cold starts. You can use pub/sub mechanisms to communicate refreshes/invalidations to all hosts, but you still have a period of inconsistency between when the write happens and when every single host has received the invalidation. When we do identify and try to fix it, it’s quite difficult to know who would have been affected unless we are logging every single HTTP request in full and which host the load balancer routed it to. Because it doesn’t surface as easily, it may go undetected and unresolved for longer. This produces an inconsistent experience for your users, where they can hit your API/site 10 times and get an incorrect result 1 or 2 those times for example. Host-level inconsistency by definition only happens some % of the time, based on the number of hosts that fell out of sync vs the ones that didn’t. This makes potential remediation a lot easier, as it’s just based on a window of time between when the database was updated and when you purge the stale cache entries. Because the inconsistency is global, it is very easy to reason about which users/requests would have been affected. We purge the entry in the distributed cache and the problem is solved. “Layer-level” inconsistency is actually fairly easy to debug and deal with. This is IMO a much more significant and undesirable type of inconsistency. Local caching introduces a much more insidious version of this failure state, where the inconsistency can happen across hosts rather than across layers of our stack. Local cache all the things! But then my pessimist personality kicks in and I started thinking about what the downsides are of doing so.ĭistributed caching introduces inconsistency as a failure state between what data our source of truth holds (the database) and what data our code has access to. From the performance side, it’s a no brainer. Assuming you can do that Redis lookup inside of. One thing that struck me is how much faster a lookup against local memory is compared to one against a distributed cache. I’ve been thinking a lot about caching recently, after reading this great write-up from Nick Craver on how they do it over at StackOverflow.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |