Design 64-bit distributed IDs and a parking lot
64-bit Distributed ID Generator
Design a service or library responsible for generating globally unique 64-bit integer IDs for database records within a distributed system. The system must meet the following requirements:
- Uniqueness: IDs must be unique across all shards and regions.
- Throughput: Support a very high write rate, estimated at 100,000 to 1,000,000 IDs per second globally.
- Ordering: IDs should be roughly time-ordered to minimize database index fragmentation.
- Scalability: The system must support sharding and an increasing number of nodes.
- Reliability: Address how to avoid ID conflicts, and discuss system behavior during failures such as node restarts, clock issues, and network partitions.
Deliverables should include a proposal for the bit layout of the IDs, the mechanism for nodes to obtain necessary configuration (e.g., worker IDs), the system's behavior under clock skew or rollback, and operational considerations like monitoring, rotation, and migrations.
Parking Lot Management System
Design a backend system for managing a parking lot. The system should handle:
- Levels and Spots: Support multiple parking levels, each with various spot types (e.g., compact, large, EV, handicapped).
- Vehicle Flow: Manage vehicle entry and exit, issue tickets, and calculate parking fees.
- Availability Tracking: Accurately track spot availability and prevent concurrent double-allocation of spots.
- APIs: Provide APIs for entering, exiting, querying spot availability, and optionally, reserving a spot.
Deliverables should cover the core classes/entities and their relationships, key APIs and the data storage approach, and the strategy for handling concurrency and consistency when assigning or freeing spots.
AI interview prep
Core dilemma
Balancing the need for high-throughput, globally unique, and roughly time-ordered IDs in a distributed environment against the inherent complexities of distributed coordination, clock synchronization, and fault tolerance.
3 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design 64-bit distributed IDs and a parking lot
64-bit Distributed ID Generator
Design a service or library responsible for generating globally unique 64-bit integer IDs for database records within a distributed system. The system must meet the following requirements:
- Uniqueness: IDs must be unique across all shards and regions.
- Throughput: Support a very high write rate, estimated at 100,000 to 1,000,000 IDs per second globally.
- Ordering: IDs should be roughly time-ordered to minimize database index fragmentation.
- Scalability: The system must support sharding and an increasing number of nodes.
- Reliability: Address how to avoid ID conflicts, and discuss system behavior during failures such as node restarts, clock issues, and network partitions.
Deliverables should include a proposal for the bit layout of the IDs, the mechanism for nodes to obtain necessary configuration (e.g., worker IDs), the system's behavior under clock skew or rollback, and operational considerations like monitoring, rotation, and migrations.
Parking Lot Management System
Design a backend system for managing a parking lot. The system should handle:
- Levels and Spots: Support multiple parking levels, each with various spot types (e.g., compact, large, EV, handicapped).
- Vehicle Flow: Manage vehicle entry and exit, issue tickets, and calculate parking fees.
- Availability Tracking: Accurately track spot availability and prevent concurrent double-allocation of spots.
- APIs: Provide APIs for entering, exiting, querying spot availability, and optionally, reserving a spot.
Deliverables should cover the core classes/entities and their relationships, key APIs and the data storage approach, and the strategy for handling concurrency and consistency when assigning or freeing spots.