You have two system-design prompts.
1) 64-bit database ID generator
Design a service/library that generates globally unique 64-bit integer IDs for database records in a distributed system.
Requirements
-
IDs must be
unique across all shards/regions
.
-
Very high write rate (assume
100K–1M IDs/sec
globally).
-
Prefer IDs that are
roughly time-ordered
to reduce index fragmentation.
-
Support
sharding
and growth in number of nodes.
-
Discuss how to
avoid conflicts
and what happens on failures (node restart, clock issues, network partitions).
Deliverables
-
Bit layout proposal (what each bit range means).
-
How nodes obtain any needed configuration (e.g., worker IDs).
-
How the system behaves under clock skew/rollback.
-
Operational considerations (monitoring, rotation, migrations).
2) Parking lot system (object-oriented + backend)
Design a parking lot management system.
Requirements (assume typical)
-
Multiple levels; each level has multiple spots of different types (compact/large/EV/handicapped).
-
Vehicles arrive/leave; system issues a ticket and calculates fees.
-
Track spot availability and prevent double-allocation under concurrency.
-
Provide APIs for: entering, exiting, querying availability, and (optionally) reserving a spot.
Deliverables
-
Core classes/entities and relationships.
-
Key APIs and data storage approach.
-
Concurrency/consistency approach for assigning/freeing spots.