{"type":"excalidraw","version":2,"source":"https://AwesomeSystemDesign.dev","elements":[{"angle":0,"strokeColor":"#6577aa","backgroundColor":"#eef1fc","fillStyle":"solid","strokeWidth":1.5,"strokeStyle":"solid","roughness":0.7,"opacity":100,"version":1,"versionNonce":1,"isDeleted":false,"groupIds":["step-1"],"frameId":null,"roundness":null,"boundElements":[{"type":"text","id":"shape-1"}],"updated":0,"link":null,"locked":false,"id":"shape-0","type":"rectangle","seed":41,"x":36,"y":31.99999999999997,"width":390,"height":480.6,"customData":{"revealStep":1}},{"angle":0,"strokeColor":"#394557","backgroundColor":"transparent","fillStyle":"solid","strokeWidth":1.5,"strokeStyle":"solid","roughness":0.7,"opacity":100,"version":1,"versionNonce":1,"isDeleted":false,"groupIds":["step-1"],"frameId":null,"roundness":null,"boundElements":null,"updated":0,"link":null,"locked":false,"id":"shape-1","type":"text","seed":114,"x":56,"y":49.99999999999997,"width":350,"height":444.6,"fontSize":18,"fontFamily":1,"text":"Cache-Aside (Lazy Loading) — Most\nCommon\n\nApp --GET--> Cache --HIT--> return\n\nMISS\n\nv\nApp --query--> DB --result--> App\n--SET--> Cache\n\n✅ Only caches data that's actually\nrequested\n✅ Cache failure doesn't break the\nsystem (falls back to DB)\n❌ Cache miss penalty (3 round trips:\ncache + DB + cache set)\n❌ Stale data until TTL expires or\nexplicit invalidation","originalText":"Cache-Aside (Lazy Loading) — Most\nCommon\n\nApp --GET--> Cache --HIT--> return\n\nMISS\n\nv\nApp --query--> DB --result--> App\n--SET--> Cache\n\n✅ Only caches data that's actually\nrequested\n✅ Cache failure doesn't break the\nsystem (falls back to DB)\n❌ Cache miss penalty (3 round trips:\ncache + DB + cache set)\n❌ Stale data until TTL expires or\nexplicit invalidation","textAlign":"center","verticalAlign":"middle","containerId":"shape-0","lineHeight":1.3,"autoResize":false,"customData":{"revealStep":1}},{"angle":0,"strokeColor":"#628572","backgroundColor":"#edf5ee","fillStyle":"solid","strokeWidth":1.5,"strokeStyle":"solid","roughness":0.7,"opacity":100,"version":1,"versionNonce":1,"isDeleted":false,"groupIds":["step-2"],"frameId":null,"roundness":null,"boundElements":[{"type":"text","id":"shape-3"}],"updated":0,"link":null,"locked":false,"id":"shape-2","type":"rectangle","seed":187,"x":466,"y":32,"width":390,"height":504,"customData":{"revealStep":2}},{"angle":0,"strokeColor":"#394557","backgroundColor":"transparent","fillStyle":"solid","strokeWidth":1.5,"strokeStyle":"solid","roughness":0.7,"opacity":100,"version":1,"versionNonce":1,"isDeleted":false,"groupIds":["step-2"],"frameId":null,"roundness":null,"boundElements":null,"updated":0,"link":null,"locked":false,"id":"shape-3","type":"text","seed":260,"x":486,"y":50,"width":350,"height":468,"fontSize":18,"fontFamily":1,"text":"Read-Through\n\nApp --GET--> Cache --HIT--> return\n\nMISS\n\nCache fetches from DB itself\n(cache library handles it)\n\nv\nCache --query--> DB --result-->\nCache --return--> App\n\n✅ Simpler application code (cache\nhandles misses)\n✅ Consistent loading logic\n❌ Cache library must know how to\nquery DB\n❌ First request for new data is\nalways slow","originalText":"Read-Through\n\nApp --GET--> Cache --HIT--> return\n\nMISS\n\nCache fetches from DB itself\n(cache library handles it)\n\nv\nCache --query--> DB --result-->\nCache --return--> App\n\n✅ Simpler application code (cache\nhandles misses)\n✅ Consistent loading logic\n❌ Cache library must know how to\nquery DB\n❌ First request for new data is\nalways slow","textAlign":"center","verticalAlign":"middle","containerId":"shape-2","lineHeight":1.3,"autoResize":false,"customData":{"revealStep":2}},{"angle":0,"strokeColor":"#a68a53","backgroundColor":"#fff7e6","fillStyle":"solid","strokeWidth":1.5,"strokeStyle":"solid","roughness":0.7,"opacity":100,"version":1,"versionNonce":1,"isDeleted":false,"groupIds":["step-3"],"frameId":null,"roundness":null,"boundElements":[{"type":"text","id":"shape-5"}],"updated":0,"link":null,"locked":false,"id":"shape-4","type":"rectangle","seed":333,"x":36,"y":576,"width":390,"height":293.40000000000003,"customData":{"revealStep":3}},{"angle":0,"strokeColor":"#394557","backgroundColor":"transparent","fillStyle":"solid","strokeWidth":1.5,"strokeStyle":"solid","roughness":0.7,"opacity":100,"version":1,"versionNonce":1,"isDeleted":false,"groupIds":["step-3"],"frameId":null,"roundness":null,"boundElements":null,"updated":0,"link":null,"locked":false,"id":"shape-5","type":"text","seed":406,"x":56,"y":594,"width":350,"height":257.40000000000003,"fontSize":18,"fontFamily":1,"text":"Write-Through\n\nApp --write--> Cache --write--> DB\n--ACK--> Cache --ACK--> App\n\n✅ Cache always has fresh data\n✅ No stale reads after writes\n❌ Write latency increases (cache +\nDB on write path)\n❌ Caches data that may never be\nread (wasted memory)","originalText":"Write-Through\n\nApp --write--> Cache --write--> DB\n--ACK--> Cache --ACK--> App\n\n✅ Cache always has fresh data\n✅ No stale reads after writes\n❌ Write latency increases (cache +\nDB on write path)\n❌ Caches data that may never be\nread (wasted memory)","textAlign":"center","verticalAlign":"middle","containerId":"shape-4","lineHeight":1.3,"autoResize":false,"customData":{"revealStep":3}},{"angle":0,"strokeColor":"#9180ac","backgroundColor":"#f4effb","fillStyle":"solid","strokeWidth":1.5,"strokeStyle":"solid","roughness":0.7,"opacity":100,"version":1,"versionNonce":1,"isDeleted":false,"groupIds":["step-4"],"frameId":null,"roundness":null,"boundElements":[{"type":"text","id":"shape-7"}],"updated":0,"link":null,"locked":false,"id":"shape-6","type":"rectangle","seed":479,"x":466,"y":576,"width":390,"height":433.8,"customData":{"revealStep":4}},{"angle":0,"strokeColor":"#394557","backgroundColor":"transparent","fillStyle":"solid","strokeWidth":1.5,"strokeStyle":"solid","roughness":0.7,"opacity":100,"version":1,"versionNonce":1,"isDeleted":false,"groupIds":["step-4"],"frameId":null,"roundness":null,"boundElements":null,"updated":0,"link":null,"locked":false,"id":"shape-7","type":"text","seed":552,"x":486,"y":594,"width":350,"height":397.8,"fontSize":18,"fontFamily":1,"text":"Write-Behind (Write-Back)\n\nApp --write--> Cache --ACK--> App\n\n(async, batched)\n\nv\nBackground worker --batch write-->\nDB\n\n✅ Fastest writes (cache ACK is\ninstant)\n✅ DB writes batched and optimized\n❌ Data loss if cache node dies\nbefore flush\n❌ Complex — need reliable queue\nbetween cache and DB","originalText":"Write-Behind (Write-Back)\n\nApp --write--> Cache --ACK--> App\n\n(async, batched)\n\nv\nBackground worker --batch write-->\nDB\n\n✅ Fastest writes (cache ACK is\ninstant)\n✅ DB writes batched and optimized\n❌ Data loss if cache node dies\nbefore flush\n❌ Complex — need reliable queue\nbetween cache and DB","textAlign":"center","verticalAlign":"middle","containerId":"shape-6","lineHeight":1.3,"autoResize":false,"customData":{"revealStep":4}},{"angle":0,"strokeColor":"#6577aa","backgroundColor":"#eef1fc","fillStyle":"solid","strokeWidth":1.5,"strokeStyle":"solid","roughness":0.7,"opacity":100,"version":1,"versionNonce":1,"isDeleted":false,"groupIds":["step-5"],"frameId":null,"roundness":null,"boundElements":[{"type":"text","id":"shape-9"}],"updated":0,"link":null,"locked":false,"id":"shape-8","type":"rectangle","seed":625,"x":36,"y":1049.8,"width":390,"height":363.6,"customData":{"revealStep":5}},{"angle":0,"strokeColor":"#394557","backgroundColor":"transparent","fillStyle":"solid","strokeWidth":1.5,"strokeStyle":"solid","roughness":0.7,"opacity":100,"version":1,"versionNonce":1,"isDeleted":false,"groupIds":["step-5"],"frameId":null,"roundness":null,"boundElements":null,"updated":0,"link":null,"locked":false,"id":"shape-9","type":"text","seed":698,"x":56,"y":1067.8,"width":350,"height":327.6,"fontSize":18,"fontFamily":1,"text":"Refresh-Ahead (Predictive)\n\nBackground thread monitors keys\napproaching TTL expiry\n→ Proactively refreshes from DB\nBEFORE they expire\n→ User never sees a cache miss\n\n✅ Zero cache-miss latency for\npredictable access patterns\n❌ Wasted refreshes for keys nobody\naccesses again\n❌ Complex — need access frequency\ntracking","originalText":"Refresh-Ahead (Predictive)\n\nBackground thread monitors keys\napproaching TTL expiry\n→ Proactively refreshes from DB\nBEFORE they expire\n→ User never sees a cache miss\n\n✅ Zero cache-miss latency for\npredictable access patterns\n❌ Wasted refreshes for keys nobody\naccesses again\n❌ Complex — need access frequency\ntracking","textAlign":"center","verticalAlign":"middle","containerId":"shape-8","lineHeight":1.3,"autoResize":false,"customData":{"revealStep":5}}],"appState":{"viewBackgroundColor":"#fbfbf8","gridSize":null},"files":{}}