Design an in-memory key-value database
OpenAISoftware Engineer · Technical ScreenLast updated
Design an in-memory key-value database evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Design an in-memory key-value database. Support set/get/delete, conditional updates (e.g., compare-and-set), TTL expiration, and atomic multi-key operations. Explain data structures to achieve O(
- average-time reads/writes, how you track expirations (e.g., timing wheel or min-heap), memory management and eviction (e.g., LRU), and persistence via append-only log with periodic snapshots. Detail concurrency control (single-threaded event loop vs locks), crash recovery, replication and sharding for scale, consistency guarantees, backpressure, and observability. Provide API definitions, schemas for on-disk records, failure modes, and metrics.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.