Design a Parking Lot Reservation System in Azure
--
A parking lot reservation system is a classic question asked during system design interviews.
One possible solution to this question may be found in this video:
The problem
The system we want to design will have two parking garages, one in East US and one in West US.
We expect 10 floors per garage, and 200 spots per floor.
We estimate an average occupancy of 30% of the available spots. Occupancy may vary during peak times when it could reach 100%.
The average length of a reservation is 2 hours.
It is given that availability and low latency are priorities, or the owner of the parking may not be able to cash in, especially during concerts or big events when demand peaks.
TPS, QPS
To estimate the number of transactions we need to:
TPS: Total Bookings per Day / 86,400 seconds per day
The total bookings in a day can be calculated considering the average capacity is 30% and that each booking last on average 2 hours.
First thing first, we need to know how many bookings are required for a spot to be completely booked for a day.
For a spot to be filled for an entire day, we would need it to be booked at 2 AM, 4 AM, 6 AM, ... that would total to 12 bookings in a day to fill a spot.
BOOKINGS TO FILL SPOT PER DAY = 24h / 2h = 12
TPD = CAPACITY * AVERAGE OCCUPANCY * BOOKINGS TO FILL SPOT PER DAY = 200 * 10 * 0,3 * 12 = 7,200
We can estimate we will handle 7,200 bookings per day per garage.
The number of transactions per second is:
TPS = 7200 / 86,400 = 5 bookings every minute
We may assume QPS would be 3 times the TPS. 15 queries per minute.