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 a receipt number.
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,
receipt_number,
status (using, leave, paid, payment_confirmed)
Payment service might have a high possibility of shutdown, so it may need to design concisely when users are paying for fee. When the user has submit the payment request to the parking service, parking_service will not only just send a request to MQ, but also generate a receipt number to the user, which will be also stored into the user_record table. In this case, when users can exit the parking lot, parking_service will check the ticket_id which the user holding whether its status is paid or not, if is paid or payment_confirmed, the user will be allow to leave. After the payment service back online, it will return the payment status to the parking_service and then update the tickets that are in paid status to payment_confirmed status. This approach actually implements a local payment record to keep track of the user parking status.
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.