Caching Strategies Cheat Sheet

  • 2 Strategies
    • Lazy loading
      • When something is requested from cache and cache misses, cache request it from origin
      • This is the strategy used by CDNs
    • Write-through
      • When origin is updated, update cache at the same time
  • Compare 🎓
    • Lazy loading
      • Good
        • Low storage needs = only cache requested data
        • Fault-tolerant = replaced nodes only increases latency but can work normally
      • Bad
        • Cache miss = latency
        • Stale data = no way to update cache when origin data is updated
          • Use TTL or use write-through
    • Write-through
      • Good
        • Up-to-date = no stale data
        • No cache miss penalty
      • Bad
        • Write penalty = every writes incurs writing to both cache and database
        • Faults result in missing data = when node is replaced there will be a time window of data not written to cache thus missing
          • Add lazy-loading
        • Wasted storage = most data are not accessed but will account into cache storage
          • Use TTL
  • Strategies not exclusive, and be combined and should


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s