Crushing Tech Education

Crushing Tech Education

Share this post

Crushing Tech Education
Crushing Tech Education
Design an Uber
Copy link
Facebook
Email
Notes
More
User's avatar
Discover more from Crushing Tech Education
Join a community of engineers and technical managers dedicated to learning System Design.
Over 3,000 subscribers
Already have an account? Sign in
System Design

Design an Uber

Two main Uber workflow and detailed design

Nov 25, 2023

Share this post

Crushing Tech Education
Crushing Tech Education
Design an Uber
Copy link
Facebook
Email
Notes
More
Share

This system is designed to efficiently connect riders with drivers, manage their interactions, and ensure a seamless travel experience. The key aspects of this system include the rider and driver workflow, location services, and the technical trade-offs between using quadtree and geohash for spatial data management.

Rider and Driver Workflow

The rider and driver workflow in Uber's system is a sophisticated process, designed to be as intuitive and efficient as possible. When a rider opens the Uber app, they input their destination, which triggers a request in the system. This request includes the rider's current location, obtained through the phone's GPS. The system then needs to quickly find available drivers nearby and send them the ride request.

On the driver's end, when they are logged into the app and ready to accept rides, the system constantly updates their location. As soon as a nearby ride request is made, drivers receive a notification. The driver can choose to accept or decline the ride. If accepted, the system facilitates navigation to the rider's location, and after pick-up, to the destination.

The workflow is designed to minimize wait times for riders and idle times for drivers, optimizing the experience for both parties. This process involves complex algorithms that consider multiple factors such as distance, traffic conditions, and the availability of drivers.

WebSockets in Uber's Real-Time Communication

WebSockets play a crucial role in Uber's system architecture by facilitating real-time bidirectional communication between the server and clients (riders and drivers). Unlike traditional HTTP requests that work on a request-response basis, WebSockets establish a persistent connection, enabling continuous data flow without the need for repeated requests. This is essential for Uber, where the real-time location of drivers, trip status updates, and dynamic pricing information must be communicated instantly to the users.

In Uber's context, once a ride is booked, a WebSocket connection is established between the user's app and the server. This connection remains active throughout the journey. The server continuously pushes updates about the driver's location, estimated time of arrival (ETA), and other relevant data directly to the user's app. Similarly, any changes or actions taken by the rider, like trip cancellation or route changes, are instantly communicated to the driver through this WebSocket connection.

Location Service: Quadtree vs. Geohash

A critical component of Uber’s system is its location service, which manages spatial data. Two popular methods for this are quadtrees and geohashes, each with its own advantages and trade-offs.

Quadtree: A quadtree is a tree data structure, which is particularly effective in managing two-dimensional spatial data. It works by recursively subdividing the space into four quadrants or nodes. In the context of Uber, this allows the system to quickly search and retrieve the locations of drivers and riders within any given area. The primary advantage of a quadtree is its efficiency in spatial queries, as it can quickly narrow down the search area. However, a significant trade-off is the complexity of implementation, especially in a dynamic environment where driver and rider locations constantly change.

Geohash: Geohash is an alternative system that converts a two-dimensional geographical location into a short string of letters and numbers. This method is particularly useful for its simplicity and ease of implementation. It works well for applications like Uber as it provides a quick way to encode and compare locations, facilitating the matching of riders and drivers. However, one of the trade-offs of using geohash is its less efficient spatial querying compared to quadtrees. Geohashes can also lead to edge-case issues at the boundaries of geohash areas, where two nearby points might end up having significantly different geohash codes.

Feel free to check a video version with more deep dive content.

Crushing Tech Education is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.

Share this post

Crushing Tech Education
Crushing Tech Education
Design an Uber
Copy link
Facebook
Email
Notes
More
Share

Discussion about this post

User's avatar
Starting an Architecture Review Team
How to start, manage, and deliver!
Feb 25, 2024 â€¢ 
SWE
 and 
Fran Soto
13

Share this post

Crushing Tech Education
Crushing Tech Education
Starting an Architecture Review Team
Copy link
Facebook
Email
Notes
More
3
Design a Coding Contest Platform like Leetcode
Remote code execution engine and database design.
Feb 3, 2024 â€¢ 
SWE
12

Share this post

Crushing Tech Education
Crushing Tech Education
Design a Coding Contest Platform like Leetcode
Copy link
Facebook
Email
Notes
More
6
Design Stock Exchange | HLD | Data Model | Reliability
Design a stock exchange, process buy and sell orders efficiently in memory
Jan 6, 2024
2

Share this post

Crushing Tech Education
Crushing Tech Education
Design Stock Exchange | HLD | Data Model | Reliability
Copy link
Facebook
Email
Notes
More

Ready for more?

© 2025 Crushing Tech Education
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More

Create your profile

User's avatar

Only paid subscribers can comment on this post

Already a paid subscriber? Sign in

Check your email

For your security, we need to re-authenticate you.

Click the link we sent to , or click here to sign in.