Register service
Ride request service
Driver matching service
Geolocation service
Payment service
Chat service
Performance : service can handle high volume of concurrent request with low latency
Compliance : the location data should be separated with user's identification data
Reliability : service can provide high system availability to ensure user can request reliably at any time with minimal downtime or system interruption
Scalability : User and driver and request would be getting more and more
DAU : 1M
Driver : 0.1M
user action on averaging : 5
request per day : 5M
RPS : 5M/(24*60*60=86400) = 60RPS
data size per request = 500B
data size per day = 2.5G
Register Service : register as driver or passenser
driver matching service : find available driver near customer
Notification service
Pricing service : calculate price
map matching service : matching location of driver and customer to map
payment service
route planing service
HTTP error code will be used
[Driver] index(location, vehicle_type)
[Customer]
[Call]
[Route_Plan]
[payment]
tech choice
driver
customer
payment
call
routeplan
data partitioning and sharding
Given distribued nature and high volume of ride-sharing platform like Uber, a suitable partitioning strategy would be Horizental partitioning and sharding based on geographical region where the data related to user, ride, driver are partitioned cross geographic region or cities.
This strategy ensures the data distributed evenly, optimazing query performance and scalability.
Consistent hashing algorithm can be used for sharding, which efficiently distribute the data when number of shard or nodes changes.
FrontEnd
Driver and passenger will communicate with server using app. It connect with chat system using web socket for real time messaging between driver and passenger.
register service
It receive user's information like name, phone number, payment method and store in MySQL.
driver service
It receive driver's information like name, phone number. and driver should register their car for ride-sharing.
chat system
payment service
In this service, I assume that we use third party payment system. this service calculate price of riding using car type, time, distance and request to third party system. price would be different the amount of demand at that time. it means surge price.
matching service
It request to mongoDB to get driver near departure location. and calculate which ride would be optimal after adding this new request.
notification service
It notify to passenser whenever the status of their request is changed such like requested, matched, driver arrived, arrived, completed. and also notify to driver after matching ride to them.
route planning service
It calculate route planning from driver to passenger and from passenger to destination. It can be bounded dijkstra algorithm or A* algorithm if there's good heuristic method.
mat matching service
It received driver's location continuously using web socket. and matching it to map using Hidden Markov chain or something and store to mongoDB in order to retrieve from backend to show to the passenser. push model would be more suitable than poll model for continuous updates of location.
RDBMS vs NoSQL : strong consistency is important for this service. RDBMS would be more good for this.
DB failure : db can be break down. we can duplicate and make replication. and using circuit breaker service can be stable.