The parking lot system will be a system that operates on multiple different parking lots, each parking lot will have a gantry that will open up to allow vehicles to enter and exit the carpark, and will charge vehicles based on the duration they are parked in the parking lot.
Lets say we are keeping track of 5,000 carparks Lets say for each carpark, 50,000 vehicles enter and exit each day.
Data to keep track of:
Storage Estimates:
Traffic Estimates:
Data to keep track of:
The above has a lot of relations, for example when a car requests to enter or exit, you will have to search for relationship in the carpark DB, gantry DB, and vehicle_entry DB. In addition, the total storage needed is not very big, and we do not need to scale very much as well.
Hence I suggest an SQL database such as MySQL or PostgreSQL to keep track of the data
We will have multiple gantries that act as clients that connect to the server that handles the entry and exit requests, the server will then connect to the SQL database
We must be able to handle traffic during peak hour, when cars are exiting from their home carparks and entering office carparks. Hence we will most likely need multiple to handle the entry and exit requests.
Assuming during peak hours, there are 5000 requests made per second, and assuming each server can handle 500 requests per second, then we minimally need 10 servers during peak hours. We will most likely need backup servers in case one or more of them goes down. Hence I suggest 12 total severs.
We will definitely need a number of load balancers between the clients and servers. I suggest a round robin algorithm to distribute the load to different servers.
In addition, we will probably need a mechanism that clears entry records in the Vehicle_entry table that are there for more than a year. Instead of allocating more servers to do that, we can employ some of our currently existing servers to clear expired data from the database only during non-peak hours (10pm - 5am).
We would also want to have backup databases just in case our main DB goes down, we can have a server that is dedicated to duplicating data from our Vehicle_Entry Table in our main DB to our back up DBs. We can employ more servers to do this during off peak hours as well.
Explain any trade offs you have made and why you made certain tech choices...
There could be a situation where the gantry barriers have been tampered with, meaning vehicles can enter and exit the carpark through gantries that are broken without a request to the server. Of course, we will need to send someone there to fix the barrier, however, this means that our count of how many available lots in the carpark will be wrong. Meaning if a vehicle tries to enter a carpark through another gantry, the server might think there are lots available, when there are not. This could cause a jam in the carpark!
what we could possibly do is to employ sensors on each lot in a carpark, when a vehicle occupies a lot, it will trigger the server to decrement the available lot count, similarly when a car exits the lot, it will trigger the server to increment the available lot count
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?