1000000 vehicle per day in one region
Schema contains vehicle number, allocation spot, some more details like entered date and updated at and exit date
2000 byte to store for single vehicle details with all the metadata
2000*10000000*365= 73000000000 bytes = 73 GB to store this info in one region
if we dd payment detail and audit details also= you can multiple 3= 250GB per year we want in the database storage.
Average vehicle enter into system per sec:->
10000000/ (24*60*60)= 100 per sec
Let say in peak time :-> 1000 per sec
we can distribute with horizontal server
/api/v1/parkinglot/service/scanVehicle
/api/v1/parkinglot/service/getAvailableSpot/vehicleType/{vehicleType}
/api/v1/parkingLot/service/assignSpot/vehicle/{vehicle_number}
/api/v1/parkingLot/service/generateTicket/vehicle/{vehicle_number}
/api/v1/parkingLot/service/exitCalculation/vehicle/{vehicle_number}
/api/v1/parkingLot/service/payment/vehicle/{vehicle_number}
User Table
id, Name, Address, Mobile number, user type
Usertype enum like Admin, guest, Operator
Vehicle Table
id, RC number, Type
ParkingLot
id, name, location, total_gate
ParkingSpot
id, status, SpotType, parkinlot
Ticket
id, vehicle_id, spot_id, enter_time, exit_time, fee, user_id
Vehicle enter into system, system scan vehicle details and system get avaialble spot in the parkinglot spots and assign available spot for specific type of vehicle.
Exit gate-> User ask to fee calculation for specific spot type and user type
Redis cache used for fast retrieval of spot details for checking available spot and do the calculation with less latency.
Database used for storing the information of spot and vehicle detail.
Payment service will process the payment to release the spot and exit to the system.
Parkinglot Service
Assign available spot :-> We can use dijkstra's algorithm to find nearest available spot in the system or we can use geospatical database to do this processing.
We can use multiple strategies for fee calculation on the basis of days and seasons.
Redis
It is used for caching the data for fast retrieval and it will give less latency
Payment Service
We can use multiple payment mode for supporting the payment strategies
Load Balancer: ->
Advantage:
It distribute the load evenly, so that single server won't get into overwhelemed state.
Disadvantage:
It is hard to manage many server for deployment and disaster faults
Database SQL:->
Advantage:-> Using sql database ensure consistency into the system and it follow ACID properties.
Disadvantage:->
Making partition tolerant will be hard because we are making system available and consistent
Database can be bottlenecks, if let say all the db instance goes down then all call will block, we need to have multi region database instance or failover database to handle that.
Payment Service also should be bottleneck, if we don't support multiple payment mode in their