Multi-level caching: L1 (in-process) + L2 (Redis) + L3 (CDN) — is it worth it?
Marcus Ahmed
·286 views
We've been thinking about implementing a multi-level caching strategy for our core services to squeeze out every bit of performance. Our current setup uses Redis as an L2 cache, which gives us decent performance, but there's still 1-2ms of network latency for every Redis hit. We're considering adding an L1 in-process cache for the absolute hottest keys to get sub-millisecond access times.
The challenge, of course, is cache coherence across our 20+ service instances. If a key is updated in the database, we'd need to invalidate it in both the L2 Redis cache and all L1 in-process caches. We're looking at using Redis Pub/Sub for sending invalidation messages to all service instances. This adds a significant layer of complexity: managing the invalidation topic, handling subscriber failures, and ensuring eventual consistency. Is this multi-level caching approach generally worth the added operational burden and complexity for single-digit millisecond gains, or are there simpler ways to optimize for those critical hot paths?
6 comments