Assume the system manages 10 parking lot with 500 spots each. Assume during peak, 10 cars exit/in per minute. Assume 50 reservations per day.
TPS
Exit/in: 10 * 2 / 60 = 0.33
Reservation: 5
Storage
Per entrance, user data is around 50b, vehicle data 50b, reservation 80b
180b * 50 request/day * 10 lot *2 years = 65.7MB
User
user_id
name
Vehicle
vehicle_id
type (enum)
user_id
plate
Reservation
reservation_id
user_id
vehicle_id
start_time
end_time
lot_id
status(confirm, complete, cancel)
payment_status(unpaid, cancelled, fulfilled)
Parking Lot
lot_id
location
Lot_Capacity
capacity_id
lot_id
vehicle type
available
Spot
spot_id
lot_id
vehicle type
status
Transaction
tx_id
user_id
vehicle_id
start_time
end_time
Reservation
Load balancer dispatches the request to the parking server to check capacity based on the vehicle type and parking lot id. If spot available, reservation server creates a reservation and saves to the database. If walk in, the reservation server creates a reservation on the fly.
Check in/out
When user arrives, the parking server records the check in time, after s/he parks, the system update database and cache with the updated reservation status, and the capacity.
When user checks out, the parking service calculates the rate and queues the payment request for payment service to process.
Cache
To improve the performance of get_capacity API, we store the
Database
The size of data is still small, we can replicate the entire database using master-slave pattern.
Need to keep cache in sync with the database
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?