We assume the parking lot has 50 slots and that 500 cars pass in the parking lot every day.
500*30 = 15000 cars park in the parking lot every month.
However, we erase the information in the database every day when the parking lot closes so we do not need much scaling.
"Assignment API" - using the "count microservice" it will be in charge of assigning slots to the different cars. The "count microservice" keeps count of how many cars are in the parking lot at a given time, and also it tracks how many vehicles of a certain type are in the parking lot. For example, when a motorcycle requests to enter the parking lot, the assignment API will reach the microservice, which will know if there is a slot for a motorcycle. If there is one, it will return the next available slot and will increment the count of motorcycles in the lot and total vehicles in the lot. Then, the new assigned slot will be stored with the vehicle's info in the DB and the API will return the response to the user.
"Cleanup API" - this API erases all the information stored from the passing day from the cache and the database once the parking lot closes for the day.
"Payment API" - The payment API is used when a vehicle wants to exit the lot. Using the vehicle's number, the Payment API will query the database, will find the proper entrance_time and will calculate the price to be payed.
a NoSQL DB that stores {vehicle_id: entrance_time, vehicle_type, assigned_slot, status}.
Using a load balancer, the request from the client (enter/exit) will be directed to the right API. Each API will perform its role and will query the database to receive the info it needs.
database: we can use a NoSQL database because we don't have a need for highly structured data or complicated joins. NoSQL will allow high throughput.
Explain any trade offs you have made and why you made certain tech choices...
can have a bottleneck at the load balancer if many cars are trying to enter at once or when the lot is full
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?