{"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":16,"y":16,"width":288,"height":93.2,"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":36,"y":34,"width":248,"height":57.2,"fontSize":22,"fontFamily":1,"text":"Fanout\nService","originalText":"Fanout\nService","textAlign":"left","verticalAlign":"middle","containerId":"shape-0","lineHeight":1.3,"autoResize":false,"customData":{"revealStep":1}},{"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-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":16,"y":153.2,"width":288,"height":93.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":36,"y":171.2,"width":248,"height":57.2,"fontSize":22,"fontFamily":1,"text":"Fanout\nService","originalText":"Fanout\nService","textAlign":"left","verticalAlign":"middle","containerId":"shape-2","lineHeight":1.3,"autoResize":false,"customData":{"revealStep":2}},{"angle":0,"strokeColor":"#6577aa","backgroundColor":"transparent","fillStyle":"solid","strokeWidth":2,"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":36,"y":260.4,"width":0,"height":28,"points":[[0,0],[0,28]],"lastCommittedPoint":null,"startBinding":{"elementId":"shape-2","focus":0,"gap":14},"endBinding":{"elementId":"shape-5","focus":0,"gap":14},"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-6"},{"type":"arrow","id":"shape-4"}],"updated":0,"link":null,"locked":false,"id":"shape-5","type":"rectangle","seed":406,"x":16,"y":302.4,"width":288,"height":121.8,"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-6","type":"text","seed":479,"x":36,"y":320.4,"width":248,"height":85.8,"fontSize":22,"fontFamily":1,"text":"Redis\n(feed\ncache)","originalText":"Redis\n(feed\ncache)","textAlign":"left","verticalAlign":"middle","containerId":"shape-5","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-8"}],"updated":0,"link":null,"locked":false,"id":"shape-7","type":"rectangle","seed":552,"x":16,"y":468.2,"width":288,"height":1780.6000000000001,"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-8","type":"text","seed":625,"x":36,"y":486.2,"width":248,"height":1744.6000000000001,"fontSize":22,"fontFamily":1,"text":"Fanout-on-Write\n(Push Model)\n\nWhen User A posts a\nphoto:\n1. Get A's follower\nlist: [B, C, D, ...\n1000 followers]\n2. Write post_id to\neach follower's feed\ncache (Redis)\n\nUser A posts\n\nC's feed: [post_new,\npost_x, post_z, ...]\nD's feed: [post_new,\npost_w, post_v, ...]\n\nv (1000 writes for\n1000 followers)\n\nWhen User B opens\nfeed:\n1. Read B's\npre-computed feed\nfrom Redis\n2. Fetch post\ndetails + images for\nthose post_ids\n3. Return immediately\n-- O(1) read\n\nPros:\n+ Feed reads are\nFAST (pre-computed,\njust read from\ncache)\n+ Simple read path\n+ Ideal for\nread-heavy workloads\n(100:1 ratio)\n\nCons:\n- Celebrity problem:\nuser with 100M\nfollowers = 100M\nwrites\nper single post\n(takes minutes, huge\ncompute)\n- Wasted work: many\nfollowers are\ninactive, never check\nfeed, but we still\nwrote to their cache\n- High write\namplification\n- Storage: every\npost duplicated in\nmillions of feeds","originalText":"Fanout-on-Write\n(Push Model)\n\nWhen User A posts a\nphoto:\n1. Get A's follower\nlist: [B, C, D, ...\n1000 followers]\n2. Write post_id to\neach follower's feed\ncache (Redis)\n\nUser A posts\n\nC's feed: [post_new,\npost_x, post_z, ...]\nD's feed: [post_new,\npost_w, post_v, ...]\n\nv (1000 writes for\n1000 followers)\n\nWhen User B opens\nfeed:\n1. Read B's\npre-computed feed\nfrom Redis\n2. Fetch post\ndetails + images for\nthose post_ids\n3. Return immediately\n-- O(1) read\n\nPros:\n+ Feed reads are\nFAST (pre-computed,\njust read from\ncache)\n+ Simple read path\n+ Ideal for\nread-heavy workloads\n(100:1 ratio)\n\nCons:\n- Celebrity problem:\nuser with 100M\nfollowers = 100M\nwrites\nper single post\n(takes minutes, huge\ncompute)\n- Wasted work: many\nfollowers are\ninactive, never check\nfeed, but we still\nwrote to their cache\n- High write\namplification\n- Storage: every\npost duplicated in\nmillions of feeds","textAlign":"left","verticalAlign":"middle","containerId":"shape-7","lineHeight":1.3,"autoResize":false,"customData":{"revealStep":3}}],"appState":{"viewBackgroundColor":"#fbfbf8","gridSize":null},"files":{}}