The parkin lot has to manage vehicle entry, exit and parking allocation.
It has to manage different types of vhicles.
The parking lot system also has to:
The parking lot system also has to:
Assumptions:
Estimate the scale of the system you are going to design...
200 parking spots
200 parking inputs / outputs (tickets) --> 73.000 tickets / year --> 365.000 tickets in 5 years
Define what APIs are expected from the system...
Vehicle entry
A new ticket is created for the number plate and vehicle type
Parking slots are queried to find recommended area based on vehicle type
Parking slot state changed
Once a sensor detects a slot stat chenage, this API is executed to update it in the database
It's used when a vehicle enters a parking spot and when it leaves it
Parking payment amount calculation
Computes the amout to pay based on the actual time and when the vehicle entered
Parking payment
Called to confirm ticket payment updating ticket payment state to allow the carr to leave the parking lot
Vehicle exit
When the vehicle wants to exit the parking lot, it checks that the ticket has been payed and stores the exit date and time
A NoSQL document DB is selected because:
Mongo DB is selected as a mature and well known option by developers and sysadmins
Indexes
Load balancer
Redirects requests to an available application server
Application serveer
Execute the system services that handle requests and implement systme functionality accessing the database.
Database
Stores tickets and parking spots status in order to provide system functionality
Analytical system
Stores information that allow the business to analyze the behaviour and plan improvements. For example to understand if some vehicle types don't have enough spots or if vehicles park in the right position
Monitoring system
Stores:
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Vehicle entry
The vehicle is at the parking barrier.
The parking barrier identifies the plate number and vehicle type and calls vehicle entry service.
The vehicle entry services:
Parking slot state changed
When the vehicle parks in a spot, the spot ussage sensor calls the parking slot state change service with it's number and floor indicating it has been used
Parking payment
The user enters tha parking ticket in the teller machine
The teller machine calls the payment amount calculation service with the tichket id
The payment amount calculation service returns the amount to pay taking into account the entry time and the current time and returns it
The teller machine shows the amount to pay and the user pays it
The teller machine calls the parking payment service with the ticket id, and the service updates the ticket as peyed
Vehicle exit
When the vehicle approaches the exit barrier, the barrier calls to the vehicle exit service with the number plate, the service checks if the ticket has been payed and, in that case, opens the barrier
A L3 load balancer is selected becauese:
The main objective is to provide availability in case of an application server fails.
The load balancer will also be in a high availability configuration
Nginx in two servers with active-passive failover is selected
For warantiing availability a replicaset with 3 nodes, in 3 different availability zones, and 5 replicas is used, allowing for a complete failure of a datacenter without service lost.
With the reduced number of requests expected, a cloud small NoSQL database could be used, for example AWS DynamoDB to reduce costs. MongoDB is preferred because:
The load of the system is very low, both for readings and writtings, so no cache will be implemented as it increases costs without a clear benefit.
For the same reason a L3 load balancer with fail-over configuration (active-passive) will be used.
The system has been design to have high availability. Even though, in case of a failure or an security emergency, the system is prepared to:
The number of requests to the system is very low so no bottleneck is expected
In order to avoid having its own hardware resources and administration, a cloud solution could be implemented:
Analyitical system that helps to understand if vehicles use their appropiate slots and help to detect usage of biger slots than needed and define measures to reduce it improving efficiency.
For improving user experience, an automatic charging system, based on highway payment system, could be implemented to allow customers exit without previous manual ticket payment. Security should be evaluated and some measure to avoid thefts may be implemented.
Vouchers or passes could be implemented to increase customers loyalty