← Openai Interview Insights

Openai·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Jun 2026

Summary

OpenAI system design round for a software engineer role, one meaty question about building a persistent key-value store from scratch. The kind of problem that sounds manageable until you're actually in it and realize how many small decisions stack up.

Questions Asked (1)

Q1

Design and implement a persistent key-value store backed by a single file. It needs to support put, get, and delete operations, survive process restarts by reconstructing state from disk on startup, and you should define your on-disk record format and talk through how you'd handle compaction.

System DesignTechnical Trade-offsData Modeling
Author's notes

I started with the in-memory HashMap part and felt fine, then they asked me to define the actual byte format and I kind of froze for a second.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and assumptions, then propose a simple append-only log design with an in-memory index for fast lookups. Walk through the record format, recovery process, and compaction strategy, emphasizing trade-offs and potential optimizations.

Pro tip: Mention that you would use a checksum per record to detect corruption and ensure durability, and discuss how compaction can be done in the background without blocking reads/writes.

1. Clarify Requirements and Assumptions

Ask about expected workload (read/write ratio, key/value sizes), durability guarantees, and performance constraints. State assumptions to scope the design.

2. Design On-Disk Record Format

Define a binary format with fields like key length, value length, key, value, timestamp, and checksum. Explain how it supports put, get, and delete (e.g., tombstones).

3. Implement In-Memory Index and Operations

Describe an in-memory hash map mapping keys to file offsets for O(1) reads. Explain how put appends to the log and updates the index, and how delete writes a tombstone.

4. Handle Startup Recovery

On startup, scan the log sequentially, rebuild the in-memory index, and ignore stale entries (e.g., overwritten keys or tombstones). Mention checksum validation to skip corrupted records.

5. Design Compaction Strategy

Propose periodic compaction: write a new log file containing only the latest live records, then atomically swap files. Discuss triggering compaction based on file size or garbage ratio, and handling concurrent access.

Key Points to Mention

  • Append-only log structure for durability and simplicity
  • In-memory index (hash map) for fast lookups
  • Record format with checksums for integrity
  • Tombstones for deletes and handling stale entries during recovery
  • Compaction to reclaim space and improve read performance
  • Trade-offs: memory usage vs. read speed, compaction overhead, crash consistency

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.