Assume the parking lot has 1000 spots. At peak, there is 0.1 request/second.
For storage, there can be at most 1000 outstanding tickets. Each ticket has less than 100 byte. So we need at most 100KB. For audit purpose, we will keep ticket for 1 year, this is 36MB of data.
get_rate() -> [ FeeInfo ]
reserve() -> Ticket
release(ticket_id) -> Fee
On reserve, the system will generate a ticket. On the ticket, it will record a ticket ID and the time of entry. The ticket ID can be randomly generated UUID (16 byte). The time of entry is a epoch timestamp (4 byte).
Ticket (20 byte)
For get_rate, we have a table of hourly range start and end and its hourly fee. For example, 0-2 hours is 5/hour.
FeeInfo
We will store current tickets in a table and used tickets in another table. This will handle the case when a UUID is reused. The FeeInfo will be in its own table.
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?