Estimation:
Daily total = 100,000 × 80 bytes = 8,000,000 bytes/day= ≈ 7.8 MB/day
In 1 year : 2.78 GB
start_time, end_time )
4. pay(reservation_id, user_id)
5. API used at gate checkin service
vehicle_arrived(reservation_ID, user_id, date_time)
vehicle_left(reservation_ID, user_id, date_time)
UserProfile Entity
CREATE TABLE user_profile (
'user_id' string primary key,
'email_id' string,
'phone_number' string,
'active' boolean,
'address' varchar(255),
)
CREATE TABLE lot (
'lot_id' string primary key,
'available' string,
'lot_capacity' string,
)
CREATE TABLE transaction (
'transaction_ID' string primary key,
'user_ID' string,
'reservation_id' string,
)
2. Rate Limiter
Purpose: Protects the system from abuse (e.g., DDoS attacks, bot overuse)
3. Ensures no single server is overwhelmed.
Improves fault tolerance and allows horizontal scaling.
Using weighted round robin allows prioritizing servers based on capacity.
4. Ensures no single server is overwhelmed.
Improves fault tolerance and allows horizontal scaling.
Using weighted round robin allows prioritizing servers based on capacity.
Clients make a request, request is routed from APP to API gateway which then sends it it load balancer from where request is routed to servers.
check_capacity() is handled by Reservation Server consulting the data in the database.
reserve_spot() is handled by Reservation Server, which creates a new entry in Reservations table.
It would create a request for payment, which is queued by Message Queue and submitted to the external Payment System.
reserve_spot() may fail if multiple users are trying to book the same spot. Return an error and ask the client to try calling reserve_spot() again.
It would also fail if the lot is full. In that case, the client should not retry. Reservation Server may return helpful information such as estimated time spots may open up in the future.
vehicle_arrived() and vehicle_left() are handled by Transaction Server, which modifies the Transaction table to keep track of vehicle checkins and checkouts.
If vehicle does not arrive after some number of hours (e.g. 24 hours), reservation would be canceled. The user would be charged for 1 day of payment.
If inconsistent state happens, e.g., vehicle_left() is called before corresponding vehicle_arrived(), administrator at the lot should be notified. The service would assume the vehicle arrived around the corresponding reservation start time.
For handling multiple request we can do scaling like adding more servers, increasing RAM size.
Tech Stacks: Java, Dropwizard, Maria DB, Aerospike, Caffeine, Singleton, Indexing.
The system is expected to store ~2.78 GB of data over 1 year, which is very manageable for any modern relational database (like PostgreSQL or MySQL).
Strong Consistency:
RDBs follow ACID (Atomicity, Consistency, Isolation, Durability) principles, ensuring that:
Structured Schema:
Parking reservations have clearly defined relationships:
Prevention:
2. Description: The system could struggle under heavy traffic like in case of concerts, cricket matches, leading to slow performance or downtime.
This would put a burden on the reservation work flow (reserve_spot(), pay()). Transaction Server would be fine, as the number of requests to Transaction Server would be limited by the physical limitation of the parking lots (i.e. how many spots they have).
To prepare for such an event, all the software components must be replicated horizontally to have enough capacity. Rate Limits have to be configured to smooth out extreme level of traffic.
The database tables must be replicated in multiple ways (e.g. a copy within data center, a copy in another data center, a copy in a different region) for fault tolerance and disaster recovery.
Backup and Data Recovery: