When a single bottleneck threatens end-to-end availability, Elevator & Ticket Booking, great LLD isolates volatile business rules behind narrow interfaces and explicit state transitions so adding a new pricing rule, eviction policy, or booking workflow never breaks existing code.
TL;DR30-second simplified summary▾
Core Mechanics: While High-Level Design (HLD) governs distributed services over networks, Low-Level Design (LLD) governs the internal architecture of a service or library: entities (identity + lifecycle), value objects (immutable.
Visual & Structural Flow: Depicts Ticket Seat Hold Lifecycle (Replacing Boolean Flag Soup) (AVAILABLE -> HELD (TTL) -> BOOKED); Guarding Check-Then-Act in Concurrent Seat Booking (User A Thread -> Striped Seat Lock -> Seat State -> User B Thread).
Trade-Offs & Production: Balance polymorphism against indirection, and striped locks against coarse synchronization. In production services, the LLD domain core (Entities, FSMs, Strategies) has zero framework or database imports—it depends only on narrow port interfaces (Clock, SeatStore.
Failure Modes & Application: Practice full end-to-end LLD implementations across caching, scheduling, and concurrency.
What is Low-Level System Design (LLD).
Why this matters: The mechanism: understand how Low-Level System Design (LLD) works from first principles.
While High-Level Design (HLD) governs distributed services over networks, Low-Level Design (LLD) governs the internal architecture of a service or library: entities (identity + lifecycle), value objects (immutable, equality by value), and stateless domain services.
Clean LLD models lifecycles as explicit Finite State Machines (FSMs) and isolates volatile rules behind Strategy, State, Observer, and Command interfaces.
Ticket Seat Hold Lifecycle (Replacing Boolean Flag Soup)
A single enum-backed State Machine eliminates impossible combinations like isHeld=true && isBooked=true.
Why boolean flags and check-then-act races break services.
Why this matters: The problem: see what breaks without Why boolean flags and check-then-act races break services under real concurrency or scale.
Poor LLD produces god classes, brittle if-else trees, and concurrency bugs at 100k+ lines of code.
Two failure modes recur constantly: boolean flag explosion (isActive, isPaused, isDeleted allowing illegal states) and check-then-act race conditions where two threads both see spot.isFree() == true and issue duplicate tickets.
Guarding Check-Then-Act in Concurrent Seat Booking
Making check-and-reserve atomic under a per-entity lock or optimistic CAS prevents double-booking.
- Problem
- How to implement Low-Level System Design: LRU Cache, Elevator & Ticket Booking without hitting unbounded tail latency, state divergence, or operational fragility.
- Naive Solution
- Use a single unpartitioned path with unbounded retries and synchronous global coordination.
- Why It Fails
- Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
- Alternatives
- Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
- Engineering Decision
- When a single bottleneck threatens end-to-end availability, elevator & Ticket Booking, great LLD isolates volatile business rules behind narrow interfaces and explicit state transitions so adding a new pricing rule, eviction policy, or booking workflow never breaks existing code.
- Trade-Offs
- Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
When Low-Level System Design: LRU Cache, Elevator & Ticket Booking experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?
Where LLD rigor pays off (and where to keep it simple).
Why this matters: Scope boundary: identify where this pattern fits best and where simpler or async alternatives win.
Think of Where LLD rigor pays off (and where to keep it simple) as the intuition layer for Low-Level System Design: LRU Cache, Elevator & Ticket Booking: Scope boundary: identify where this pattern fits best and where simpler or async alternatives win.
Apply full domain modeling to core engines with evolving rules and concurrent state.
| Choice | What it buys | What it costs |
|---|---|---|
| Good Candidate: Core Engines & SDKs | Rate limiters, LRU caches, order matchers, elevator/parking schedulers, and payment pipelines. | More upfront interfaces and unit test scaffolding. |
| Avoid: One-Off Scripts & Glue Code | Keep 100-line migration scripts procedural; don't add 6 AbstractFactory layers before a second variant exists. | Premature abstraction scatters trivial logic across dozens of files. |
Explicit Transition Table + Striped Locking.
Why this matters: Operational control: configure bounds, failure handling, and safe production defaults.
Think of Explicit Transition Table + Striped Locking as the intuition layer for Low-Level System Design: LRU Cache, Elevator & Ticket Booking: Operational control: configure bounds, failure handling, and safe production defaults.
Define an explicit (currentState, event) -> nextState transition map and inject Clock and Repository interfaces so time-dependent TTL logic is 100% unit-testable.
Explicit Transition Table + Striped Locking
public enum SeatStatus { AVAILABLE, HELD, BOOKED }
public final class Seat {
private SeatStatus status = SeatStatus.AVAILABLE;
private Instant holdExpiresAt = Instant.EPOCH;
private final ReentrantLock lock = new ReentrantLock();
public boolean tryHold(Instant now, Duration ttl) {
lock.lock();
try {
if (status == SeatStatus.BOOKED) return false;
if (status == SeatStatus.HELD && now.isBefore(holdExpiresAt)) return false;
status = SeatStatus.HELD;
holdExpiresAt = now.plus(ttl);
return true;
} finally {
lock.unlock();
}
}
}
Alternatives: Pattern Extensibility vs. Procedural Simplicity.
Why this matters: The trade-off: compare competing approaches across latency, consistency, and operational cost.
Think of Alternatives: Pattern Extensibility vs. Procedural Simplicity as the intuition layer for Low-Level System Design: LRU Cache, Elevator & Ticket Booking: The trade-off: compare competing approaches across latency, consistency, and operational cost.
Balance polymorphism against indirection, and striped locks against coarse synchronization.
Alternatives: Pattern Extensibility vs. Procedural Simplicity
| Choice | What it buys | What it costs |
|---|---|---|
| Interfaces + Strategy/State | Trivial to swap algorithms, mock clocks/stores, and add variants without touching callers. | Over-abstracting stable code slows onboarding. |
| Striped Per-Entity Locks | High multi-core throughput across independent seats/accounts. | Multi-entity transfers require canonical lock ordering to avoid deadlocks. |
Clean Domain Core + Pluggable Adapters (Hexagonal LLD).
Why this matters: Production architecture: see how the components compose end to end under real load.
Think of Clean Domain Core + Pluggable Adapters (Hexagonal LLD) as the intuition layer for Low-Level System Design: LRU Cache, Elevator & Ticket Booking: Production architecture: see how the components compose end to end under real load.
In production services, the LLD domain core (Entities, FSMs, Strategies) has zero framework or database imports—it depends only on narrow port interfaces (Clock, SeatStore, PaymentGateway), allowing deterministic in-memory unit tests at 10,000 tests/sec.
Clean Domain Core + Pluggable Adapters (Hexagonal LLD)
Inject Clock, Never Call Instant.now() Directly
Testing 5-minute seat-hold expiry takes 0 ms when time is injected via java.time.Clock.
Lock Ordering for Multi-Seat Checkout
Sort selected seatIds before acquiring Seat.lock to guarantee deadlock-free group bookings.
Classic LLD Problems & Design Concepts.
Why this matters: Applied problems: connect these internals to concrete system design and debugging scenarios.
Think of Classic LLD Problems & Design Concepts as the intuition layer for Low-Level System Design: LRU Cache, Elevator & Ticket Booking: Applied problems: connect these internals to concrete system design and debugging scenarios.
Practice full end-to-end LLD implementations across caching, scheduling, and concurrency.
Practice: Make the trade-off yourself.
Why should an LLD Seat or Order entity replace independent booleans (isHeld, isBooked, isCancelled) with a single enum-backed State Machine?