PracHub
QuestionsLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/OpenAI

Implement a Recoverable In-Memory Key-Value Store

Last updated: Jul 28, 2026

Quick Overview

Build a single-process in-memory key-value store that can recover from its local append-only history after a crash. Define its durability contract and address torn writes, corruption, concurrent callers, startup cost, compaction, arbitrary byte values, and failure testing.

  • medium
  • OpenAI
  • Software Engineering Fundamentals
  • Software Engineer

Implement a Recoverable In-Memory Key-Value Store

Company: OpenAI

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

# Implement a Recoverable In-Memory Key-Value Store Design and implement a single-process key-value store whose working set is held in memory and whose state can be recovered from a local append-only log after a process crash. Support `put(key, value)`, `get(key)`, and `delete(key)`. Keys and values are byte strings. State the durability guarantee of a successful write, define the on-disk record format, and explain startup recovery. Include corruption handling, concurrent callers, log growth, and safe compaction. ### Constraints & Assumptions - There is one process and one active writer for the log. - The process can crash during any record write. - Recovery must never invent a write that was not completely recorded. - Values may contain arbitrary bytes, so delimiters alone are insufficient. ### Clarifying Questions to Ask - Must each successful mutation survive power loss, or only process restart? - Is compare-and-set or multi-key atomicity required? - How large may the data set and log become? - May startup discard a torn final record, and what should happen on corruption in the middle? ### What a Strong Answer Covers - An in-memory map plus serialized append path - Length-delimited, versioned records with operation type and checksum - A precise write, flush, and acknowledgment order - Deterministic replay and safe handling of a partial tail - Locking or single-writer coordination for concurrent calls - Snapshot or compaction with atomic file replacement - Failure injection and recovery tests ### Follow-up Questions - How would you add transactions? - How would you reduce recovery time for a very large log? - What changes when several processes need access? - How would you detect storage corruption that is not confined to the tail?

Quick Answer: Build a single-process in-memory key-value store that can recover from its local append-only history after a crash. Define its durability contract and address torn writes, corruption, concurrent callers, startup cost, compaction, arbitrary byte values, and failure testing.

Related Interview Questions

  • Design First-Fit and Best-Fit Memory Allocation - OpenAI (medium)
  • Clarify and Design Social-Graph Milestones - OpenAI (medium)
  • Implement A Mobile Chat Interface In An Existing Codebase - OpenAI (medium)
  • Count Machines and Recover a Distributed Tree Topology - OpenAI (medium)
|Home/Software Engineering Fundamentals/OpenAI

Implement a Recoverable In-Memory Key-Value Store

OpenAI logo
OpenAI
Jun 29, 2026, 12:00 AM
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
0
0

Implement a Recoverable In-Memory Key-Value Store

Design and implement a single-process key-value store whose working set is held in memory and whose state can be recovered from a local append-only log after a process crash.

Support put(key, value), get(key), and delete(key). Keys and values are byte strings. State the durability guarantee of a successful write, define the on-disk record format, and explain startup recovery. Include corruption handling, concurrent callers, log growth, and safe compaction.

Constraints & Assumptions

  • There is one process and one active writer for the log.
  • The process can crash during any record write.
  • Recovery must never invent a write that was not completely recorded.
  • Values may contain arbitrary bytes, so delimiters alone are insufficient.

Clarifying Questions to Ask Guidance

  • Must each successful mutation survive power loss, or only process restart?
  • Is compare-and-set or multi-key atomicity required?
  • How large may the data set and log become?
  • May startup discard a torn final record, and what should happen on corruption in the middle?

What a Strong Answer Covers Guidance

  • An in-memory map plus serialized append path
  • Length-delimited, versioned records with operation type and checksum
  • A precise write, flush, and acknowledgment order
  • Deterministic replay and safe handling of a partial tail
  • Locking or single-writer coordination for concurrent calls
  • Snapshot or compaction with atomic file replacement
  • Failure injection and recovery tests

Follow-up Questions Guidance

  • How would you add transactions?
  • How would you reduce recovery time for a very large log?
  • What changes when several processes need access?
  • How would you detect storage corruption that is not confined to the tail?
Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More OpenAI•More Software Engineer•OpenAI Software Engineer•OpenAI Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 9,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.