{"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"},{"type":"arrow","id":"shape-4"}],"updated":0,"link":null,"locked":false,"id":"shape-0","type":"rectangle","seed":41,"x":36,"y":32.00000000000001,"width":192,"height":82.80000000000001,"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":50.000000000000014,"width":152,"height":46.800000000000004,"fontSize":18,"fontFamily":1,"text":"Fanout\nService","originalText":"Fanout\nService","textAlign":"center","verticalAlign":"middle","containerId":"shape-0","lineHeight":1.3,"autoResize":false,"customData":{"revealStep":1}},{"angle":0,"strokeColor":"#7c899d","backgroundColor":"transparent","fillStyle":"solid","strokeWidth":1.5,"strokeStyle":"solid","roughness":0.4,"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-4","type":"arrow","seed":333,"x":132,"y":114.80000000000001,"width":0,"height":82,"points":[[0,0],[0,41],[0,82]],"lastCommittedPoint":null,"startBinding":{"elementId":"shape-0","focus":0,"gap":1},"endBinding":{"elementId":"shape-2","focus":0,"gap":1},"startArrowhead":null,"endArrowhead":"arrow","elbowed":false,"customData":{"revealStep":2}},{"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"},{"type":"arrow","id":"shape-4"}],"updated":0,"link":null,"locked":false,"id":"shape-2","type":"rectangle","seed":187,"x":36,"y":196.8,"width":192,"height":106.2,"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":56,"y":214.8,"width":152,"height":70.2,"fontSize":18,"fontFamily":1,"text":"Redis\n(feed\ncache)","originalText":"Redis\n(feed\ncache)","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-6"}],"updated":0,"link":null,"locked":false,"id":"shape-5","type":"rectangle","seed":406,"x":36,"y":343,"width":594.25916,"height":699,"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-6","type":"text","seed":479,"x":56,"y":361,"width":554.25916,"height":663,"fontSize":17,"fontFamily":1,"text":"Fanout-on-Write (Push Model)\n\nWhen User A posts a photo:\n1. Get A's follower list: [B, C, D, ... 1000 followers]\n2. Write post_id to each follower's feed cache (Redis)\n\nUser A posts\n\nC's feed: [post_new, post_x, post_z, ...]\nD's feed: [post_new, post_w, post_v, ...]\n\nv (1000 writes for 1000 followers)\n\nWhen User B opens feed:\n1. Read B's pre-computed feed from Redis\n2. Fetch post details + images for those post_ids\n3. Return immediately -- O(1) read\n\nPros:\n+ Feed reads are FAST (pre-computed, just read from cache)\n+ Simple read path\n+ Ideal for read-heavy workloads (100:1 ratio)\n\nCons:\n- Celebrity problem: user with 100M followers = 100M writes\nper single post (takes minutes, huge compute)\n- Wasted work: many followers are inactive, never check\nfeed, but we still wrote to their cache\n- High write amplification\n- Storage: every post duplicated in millions of feeds","originalText":"Fanout-on-Write (Push Model)\n\nWhen User A posts a photo:\n1. Get A's follower list: [B, C, D, ... 1000 followers]\n2. Write post_id to each follower's feed cache (Redis)\n\nUser A posts\n\nC's feed: [post_new, post_x, post_z, ...]\nD's feed: [post_new, post_w, post_v, ...]\n\nv (1000 writes for 1000 followers)\n\nWhen User B opens feed:\n1. Read B's pre-computed feed from Redis\n2. Fetch post details + images for those post_ids\n3. Return immediately -- O(1) read\n\nPros:\n+ Feed reads are FAST (pre-computed, just read from cache)\n+ Simple read path\n+ Ideal for read-heavy workloads (100:1 ratio)\n\nCons:\n- Celebrity problem: user with 100M followers = 100M writes\nper single post (takes minutes, huge compute)\n- Wasted work: many followers are inactive, never check\nfeed, but we still wrote to their cache\n- High write amplification\n- Storage: every post duplicated in millions of feeds","textAlign":"left","verticalAlign":"middle","containerId":"shape-5","lineHeight":1.3,"autoResize":false,"customData":{"revealStep":3}}],"appState":{"viewBackgroundColor":"#fbfbf8","gridSize":null},"files":{}}