-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstagram.drawio
More file actions
162 lines (162 loc) · 16.9 KB
/
Copy pathinstagram.drawio
File metadata and controls
162 lines (162 loc) · 16.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36" version="27.0.3">
<diagram name="Page-1" id="vdNY1qTGFPdmF7neDUim">
<mxGraphModel dx="1205" dy="1884" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="jyxcvMULES4GOVXY8YTx-1" value="<h1>Instagram</h1>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="360" y="-2" width="140" height="70" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-2" value="<h2>Functional Requirements</h2><div><ol><li style="text-align: left;">Create posts with photos/videos and caption</li><li style="text-align: left;">Follow other users</li><li style="text-align: left;">See combined feed of followed users</li></ol></div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="20" y="68" width="300" height="120" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-3" value="<h2>Out of Scope</h2><div><ul><li style="text-align: left;">commenting</li><li style="text-align: left;">liking</li></ul></div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="340" y="193" width="140" height="110" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-4" value="<h2>Non functional Requirements</h2><div><ul><li style="text-align: left;">eventual consistency (availability &gt; consistency)</li><li style="text-align: left;">feed load &lt; 500ms</li><li style="text-align: left;">media delivery &lt; 500ms</li><li style="text-align: left;">500M DAU</li></ul></div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="510" y="68" width="320" height="130" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-5" value="<h2>Core Entities</h2><div>User | Post | Media | Follows</div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;flipV=1;" vertex="1" parent="1">
<mxGeometry x="530" y="203" width="180" height="80" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-6" value="<h2>API</h2><div style="text-align: left;"><br></div><div style="text-align: left;">POST /posts { media, caption } -&gt; Post.id</div><div style="text-align: left;">POST /follow { followedId } -&gt; 200</div><div style="text-align: left;">GET /feed?cursor={}&amp;limit={}</div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="40" y="198" width="240" height="120" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-9" value="" style="whiteSpace=wrap;html=1;shape=mxgraph.basic.oval_callout;direction=west;" vertex="1" parent="1">
<mxGeometry x="410" y="100" width="120" height="70" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-7" value="Photos &lt; 8Mb<div>Videos &lt; 4GB</div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;flipV=0;flipH=0;" vertex="1" parent="1">
<mxGeometry x="425" y="120" width="100" height="40" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-10" value="<h2>High Level Design</h2>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="330" y="313" width="180" height="60" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-15" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-11" target="jyxcvMULES4GOVXY8YTx-12">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-11" value="" style="html=1;verticalLabelPosition=bottom;align=center;labelBackgroundColor=#ffffff;verticalAlign=top;strokeWidth=2;strokeColor=#0080F0;shadow=0;dashed=0;shape=mxgraph.ios7.icons.user;" vertex="1" parent="1">
<mxGeometry x="100" y="420" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-18" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-12">
<mxGeometry relative="1" as="geometry">
<mxPoint x="294.79999999999995" y="435" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-12" value="" style="points=[];aspect=fixed;html=1;align=center;shadow=0;dashed=0;fillColor=#FF6A00;strokeColor=none;shape=mxgraph.alibaba_cloud.apigateway;" vertex="1" parent="1">
<mxGeometry x="210" y="414.15" width="43.199999999999996" height="41.699999999999996" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-32" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-16">
<mxGeometry relative="1" as="geometry">
<mxPoint x="240" y="570" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-16" value="API Gateway" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="185" y="458" width="90" height="30" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-21" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-19" target="jyxcvMULES4GOVXY8YTx-20">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-19" value="Follower Service" style="shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;" vertex="1" parent="1">
<mxGeometry x="300" y="405" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-20" value="DB" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" vertex="1" parent="1">
<mxGeometry x="480" y="395" width="60" height="80" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-27" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.75;exitDx=0;exitDy=0;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-22" target="jyxcvMULES4GOVXY8YTx-26">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-22" value="Post Service" style="shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;" vertex="1" parent="1">
<mxGeometry x="300" y="490" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-24" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-22" target="jyxcvMULES4GOVXY8YTx-20">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-25" value="" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.s3;fillColor=#E05243;gradientColor=none;" vertex="1" parent="1">
<mxGeometry x="550" y="475" width="50" height="55" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-26" value="Blob Service (S3/Glacier)" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="510" y="530" width="160" height="30" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-37" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-28" target="jyxcvMULES4GOVXY8YTx-35">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-28" value="Feed Service" style="shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;" vertex="1" parent="1">
<mxGeometry x="300" y="570" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-31" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-29" target="jyxcvMULES4GOVXY8YTx-28">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-29" value="" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.sqs;fillColor=#D9A741;gradientColor=none;" vertex="1" parent="1">
<mxGeometry x="220" y="575" width="46.65" height="50" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-30" value="Message Queue (SQS)" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="175" y="628" width="150" height="30" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-34" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.617;entryDx=0;entryDy=0;entryPerimeter=0;exitX=0.911;exitY=-0.067;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-16" target="jyxcvMULES4GOVXY8YTx-22">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="270" y="456" />
<mxPoint x="270" y="508" />
<mxPoint x="280" y="508" />
<mxPoint x="280" y="527" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-35" value="" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.redis;fillColor=#2E73B8;gradientColor=none;" vertex="1" parent="1">
<mxGeometry x="450" y="580" width="40" height="40" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-36" value="Precomputed Feed Cache" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="390" y="628" width="160" height="30" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-38" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-22" target="jyxcvMULES4GOVXY8YTx-35">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="450" y="540" />
<mxPoint x="450" y="580" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-40" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0;entryDx=0;entryDy=27.5;entryPerimeter=0;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-39" target="jyxcvMULES4GOVXY8YTx-20">
<mxGeometry relative="1" as="geometry">
<mxPoint x="720" y="410" as="targetPoint" />
<Array as="points">
<mxPoint x="680" y="423" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-41" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.569;entryY=0.867;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-39" target="jyxcvMULES4GOVXY8YTx-26">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="620" y="580" />
<mxPoint x="601" y="580" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-39" value="Media Processing Service" style="shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;" vertex="1" parent="1">
<mxGeometry x="560" y="613" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-45" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="jyxcvMULES4GOVXY8YTx-42" target="jyxcvMULES4GOVXY8YTx-11">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-42" value="" style="points=[];aspect=fixed;html=1;align=center;shadow=0;dashed=0;fillColor=#FF6A00;strokeColor=none;shape=mxgraph.alibaba_cloud.cdn_content_distribution_network;" vertex="1" parent="1">
<mxGeometry x="89.5" y="487.7" width="51" height="42.3" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-43" value="CDN" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="85" y="538" width="50" height="30" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-46" value="multipart upload" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="60" y="375" width="110" height="30" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-47" value="<h2>Deep Dives</h2>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="350" y="693" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-48" value="Feed Load &lt; 500ms:<div><ul><li>fan-out on write for most (&lt;100k followers). Precompute feed and stores in Redis Cache (LRU, Redis Cluster/Sentinel)</li><li>fan-out on read for popular (&gt;100k followers)</li><li>add index on Post.userId, createdAt and Followers.followerId,followedId</li></ul>Media Delivery &lt; 500ms:</div><div style=""><ul><li>S3 multipart upload + s3 pre-signed links</li><li>Dynamic media optimization: Media processing services generates optimized/resized images/lower rate videos</li><li>CDN. Less popular content shorter TTL&nbsp;</li></ul></div>" style="text;html=1;align=left;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="85" y="760" width="690" height="180" as="geometry" />
</mxCell>
<mxCell id="jyxcvMULES4GOVXY8YTx-49" value="<div style=""><span style="background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(255, 255, 255));">Post:&nbsp;</span></div><div><ul><li>id</li><li>userId</li><li>s3links</li><li>caption</li><li>createdAt</li></ul><div>Followers:</div></div><div><ul><li>id</li><li>followerId</li><li>followedId</li><li>createdAt</li></ul></div>" style="text;html=1;align=left;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="710" y="420" width="120" height="220" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>