-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuber.drawio
More file actions
151 lines (151 loc) · 16.7 KB
/
Copy pathuber.drawio
File metadata and controls
151 lines (151 loc) · 16.7 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
<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="26.2.14">
<diagram name="Page-1" id="Ofg-lrRc5zlrJ35_E0Fd">
<mxGraphModel dx="1205" dy="784" 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="I8cwz5ZWIhXihqtpy3hv-13" value="Actor" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="75" y="402" width="30" height="40" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-1" value="<h1>Uber</h1>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="380" width="80" height="70" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-2" value="<h2 style="text-align: left;">Functional Requirements</h2><div><ul><li style="text-align: left;">Riders input location/destination and get estimate</li><li style="text-align: left;">Riders request ride based on estimate</li><li style="text-align: left;">Riders are matched with available nearby drivers</li><li style="text-align: left;">Drivers accept/deny requests &amp; navigate to pickup/dropoff</li></ul><h2 style="text-align: left;">Out of Scope</h2></div><div><ul><li style="text-align: left;">riders rate drivers/drivers rate riders</li><li style="text-align: left;">riders schedule future rides</li><li style="text-align: left;">riders requests different categories&nbsp;</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="20" y="30" width="370" height="230" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-3" value="<h2>Non-Functional Requirements</h2><div><ul><li style="text-align: left;">Low latency matching &lt; 1m</li><li style="text-align: left;">Strong consistency for matching (no "double booking" drivers)</li><li style="text-align: left;">High throughput during peak &lt;100 simultaneous req/location</li></ul><h2 style="text-align: left;"><span style="white-space: pre;">	</span>Out of Scope</h2></div><div><ul><li style="text-align: left;">privacy (GDPR)/security</li><li style="text-align: left;">resiliency to failures (redundancy/failover)</li><li style="text-align: left;">easy deployments (CI/CD)</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="460" y="50" width="390" height="210" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-4" value="<h2>Core Entities</h2><div>Driver | Rider | Location | Fare | Ride</div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;labelBackgroundColor=none;textShadow=0;labelBorderColor=none;rounded=1;glass=0;direction=west;strokeColor=default;" vertex="1" parent="1">
<mxGeometry x="270" y="160" width="220" height="80" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-5" value="<h2>API</h2>" 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="250" width="50" height="60" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-6" value="POST /fare { from, to } -&gt; Fare" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="120" y="290" width="180" height="30" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-8" value="POST /ride { fareId } -&gt; Ride&nbsp;" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="120" y="312" width="180" height="30" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-9" value="POST /driver/location {location} -&gt; Ok | Error" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="450" y="290" width="260" height="30" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-10" value="PATCH /ride/:rideId/accept|deny -&gt; Ok | Error" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="450" y="312" width="260" height="30" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-12" 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="320" y="342" width="180" height="60" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-16" value="Rider" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fillColor=#f5f5f5;fontColor=#333333;strokeColor=#666666;" vertex="1" parent="1">
<mxGeometry x="60" y="442" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-17" value="LB + API GW" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="190" y="412" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-18" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="I8cwz5ZWIhXihqtpy3hv-16" target="I8cwz5ZWIhXihqtpy3hv-17">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="120" y="482" as="sourcePoint" />
<mxPoint x="170" y="432" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-22" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="I8cwz5ZWIhXihqtpy3hv-19" target="I8cwz5ZWIhXihqtpy3hv-21">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-36" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="I8cwz5ZWIhXihqtpy3hv-19" target="I8cwz5ZWIhXihqtpy3hv-31">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-19" value="Ride Service" style="shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;" vertex="1" parent="1">
<mxGeometry x="370" y="472" width="120" height="30" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-21" value="3rd party mapping" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="350" y="412" width="160" height="38" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-23" value="Ride DB" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="530" y="450" width="70" height="68" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-24" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="I8cwz5ZWIhXihqtpy3hv-17">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="320" y="540" as="sourcePoint" />
<mxPoint x="370" y="490" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-25" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="I8cwz5ZWIhXihqtpy3hv-19" target="I8cwz5ZWIhXihqtpy3hv-23">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="480" y="530" as="sourcePoint" />
<mxPoint x="530" y="480" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-26" value="Actor" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="75" y="502" width="30" height="40" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-27" value="Driver" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fillColor=#f5f5f5;fontColor=#333333;strokeColor=#666666;" vertex="1" parent="1">
<mxGeometry x="60" y="542" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-28" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=1;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="I8cwz5ZWIhXihqtpy3hv-27">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="140" y="509" as="sourcePoint" />
<mxPoint x="190" y="459" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-29" value="Location Service" style="shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;" vertex="1" parent="1">
<mxGeometry x="370" y="572" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-30" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=1;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="I8cwz5ZWIhXihqtpy3hv-17">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="320" y="630" as="sourcePoint" />
<mxPoint x="370" y="580" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-35" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="I8cwz5ZWIhXihqtpy3hv-31" target="I8cwz5ZWIhXihqtpy3hv-27">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-31" value="Notification Service (APN/FCM)" style="shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;" vertex="1" parent="1">
<mxGeometry x="170" y="560" width="120" height="50" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-37" value="Location DB (Redis)" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="530" y="560" width="70" height="70" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-38" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.36;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="I8cwz5ZWIhXihqtpy3hv-29" target="I8cwz5ZWIhXihqtpy3hv-37">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="460" y="630" as="sourcePoint" />
<mxPoint x="510" y="580" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-40" value="RideDB:<div>Fare: id, riderId, source, destination, ETA, estimate</div><div>Ride: riderId, driverId, fareId</div><div>Driver: id, name, car, status</div>" style="text;html=1;align=left;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="560" y="370" width="290" height="70" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-41" value="Message Queue (Kafka)" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="390" y="522" width="100" height="28" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-42" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="I8cwz5ZWIhXihqtpy3hv-41">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="390" y="550" as="sourcePoint" />
<mxPoint x="440" y="500" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-43" value="<h2>Deep Dives</h2><div><ol><li style="text-align: left;">Handle frequent driver location updates &amp; efficient proximity searches:</li><ul><li style="text-align: left;">write heavy db/queries inefficient</li><li style="text-align: left;">use Redis + geohashing, GEOSEARCH for searches</li><li style="text-align: left;">enable Redis persistence/Redis sentinel, sharding geographically.&nbsp;</li><li style="text-align: left;">location should expire with TTL 30 minutes. Offline process can aggregate before expiration for analysis</li></ul><li style="text-align: left;">Manage system overload from frequent driver updates while ensuring location accuracy</li><ul><li style="text-align: left;">adaptive location update intervals: dynamically update frequency of updates depending on current conditions</li><li style="text-align: left;">challenge: think of an efficient algorithm</li></ul><li style="text-align: left;">Prevent multiple rides from being sent to the same driver:</li><ul><li style="text-align: left;">distributed Redis lock + TTL. Ride service needs to check if driver is locked (as well as driver's status)</li></ul><li style="text-align: left;">Ensure no rider requests are being dropped during peek</li><ul><li style="text-align: left;">add a message queue (SNS or Kafka)</li></ul><li style="text-align: left;">Further scale to reduce latency and improve throughput</li><ul><li style="text-align: left;">geosharding with read replicas</li><li style="text-align: left;">consistent hashing + replication strategy</li></ul></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="60" y="630" width="680" height="290" as="geometry" />
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-47" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="459" y="522" as="sourcePoint" />
<mxPoint x="459" y="500" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-48" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="424" y="522" as="sourcePoint" />
<mxPoint x="424" y="500" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="I8cwz5ZWIhXihqtpy3hv-49" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="409.5" y="524" as="sourcePoint" />
<mxPoint x="409.5" y="502" as="targetPoint" />
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>