Estimate the scale of the system you are going to design...
vehicle_enter(parking_lot_id, vehicle_type); return a number that can be a ticket_id
vehicle_exit(parking_lot_id, ticket_id, vehicle_type);
check whether the ticket has been paid or not: if not paid, return false, otherwise, return true.
pay(parking_lot_id, ticket_id): return true if payment is successful, otherwise return false.
show_capacity(parking_lot_id): return the current capacity.
parking_lot:
parking_lot_id,
lot_capacity_id,
status
lot_capacity:
lot_capacity_id,
spot_type (Compact, Large, Handicapped, Motorcycle, etc. ),
spot_capacity,
spot_used_number
user_record:
ticket_id,
parking_lot_id,
start_time,
end_time,
status (using, leave, paid)
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...
The biggest decision point was the database. For this service, I chose Relational Database over NoSQL Database. Because RDB provides strong consistency, which is beneficial for a payment service. Users can not leave util they pay for their parking fee, which is need to be 100% sure in this situation.
NoSQL database, for example MongoDB, would provide a better horizontal scalability than RDB. But for this service, I decided the benefit of RDB outweighs that of NoSQL DB.
I think when a super show ends, a large number of uses will pay for their fee, at the same time the MQ and the payment service will be very stressful.
To mitigate this problem, payment service should be planning to scale up to a certain capacity to consume all the request received from the MQ. MQ should also be prepared to scale up, to prevent a large number of message arrival.