The interview problem

Practice prompt

An LSM-based store accumulates immutable files faster than it can compact them. Design admission and background scheduling before the disk fills.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Assume sorted immutable runs, a mutable buffer and measured storage bandwidth. Track incoming logical bytes, flush backlog, compaction debt and free-space reserve. Select compaction work by debt and overlap while reserving resources for foreground reads and log writes. Throttle ingestion before emergency space exhaustion. Publish new run manifests only after outputs are complete; old inputs remain recoverable until no reader needs them.

2. Trace the design or derivation

Ingest
  → flush immutable runs
  → measure debt
  → compact
  → publish manifest

Admission needs a recovery hysteresis: reopen writes only after debt and space fall below safe thresholds, not immediately after one compaction finishes. Otherwise alternating stalls and bursts recreate overload. Expose separate counters for logical ingestion, physical rewrites and temporary bytes so operators can identify the limiting resource.

3. Calculate the example

At 100 MB/s logical ingestion and an assumed total write amplification of eight, required device writes are about 800 MB/s, excluding reads. A device sustaining 600 MB/s cannot keep up indefinitely. Reducing admitted logical ingestion to 60 MB/s lowers that modeled write demand to 480 MB/s, leaving 120 MB/s of write headroom, not necessarily enough read bandwidth.

4. Failure cases and trade-offs

Compaction temporarily holds both inputs and outputs. A free-space policy considering only final size can deadlock progress. Leveling can reduce read amplification while increasing rewrite work; tiering changes those costs. The best policy depends on key churn and workload, not a universal amplification constant.

5. Validation, follow-ups and self-review

Replay sustained ingestion and overwrite-heavy workloads with disk/CPU limits. Verify crash-safe manifest switching and bounded debt. Follow-up: which traffic is throttled first? Reward separate logical/physical bandwidth and temporary-space accounting.

Sources and related practice

Technical reference: github.com — Compaction policies and amplification trade-offs.

Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Compact an event log without resurrecting deleted keys; Batch durable commits without acknowledging volatile data.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.