← Openai Interview Insights

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

SeniorPrefer not to say
Jun 2026

Summary

OpenAI system design round, one big question about building a durable key-value store from scratch. The scope was wider than I expected and the disk-persistence angle made it feel less like a typical KV store question and more like a mini storage engine design.

Questions Asked (1)

Q1

Design a key-value store where data is sharded across multiple fixed-size files on disk. The system must support graceful shutdown (flush to disk durably) and restore on startup (reload state from disk). Serialization helpers are provided. Walk through shard selection, per-shard file format, shutdown consistency guarantees, and how you rebuild the in-memory index on restore.

System DesignTechnical Trade-offsData Modeling
Author's notes

This one spiraled fast.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then propose a consistent hashing scheme for shard selection and a log-structured file format per shard. Walk through the write path, shutdown flush with fsync, and startup recovery that rebuilds the in-memory index by scanning files.

Pro tip: Emphasize durability guarantees: use fsync on file and directory, and consider a write-ahead log or checksums to handle partial writes. Also discuss trade-offs between read/write amplification and recovery time.

1. Clarify Requirements and Constraints

Ask about expected data size, read/write ratio, latency requirements, and consistency needs. Confirm that files are fixed-size and serialization helpers are provided.

2. Design Shard Selection

Propose a sharding strategy, e.g., consistent hashing or modulo on key hash, to map keys to shards. Discuss how to handle shard growth and rebalancing if needed.

3. Define Per-Shard File Format

Describe a log-structured format: append-only records with key, value, timestamp, and checksum. Mention compaction or garbage collection for space reclamation.

4. Ensure Graceful Shutdown and Durability

On shutdown, flush all in-memory buffers to disk, fsync files and directory, and optionally write a manifest. Discuss atomicity and crash consistency.

5. Implement Restore and Index Rebuild

On startup, scan each shard file, validate checksums, and rebuild the in-memory index (e.g., hash map) by replaying records. Handle partial writes and corruption.

Key Points to Mention

  • Consistent hashing for shard selection to minimize rebalancing
  • Log-structured merge (LSM) or append-only file format for efficient writes
  • Use of fsync and directory sync for durability
  • Checksums to detect and handle partial writes or corruption
  • In-memory index (e.g., hash map) mapping keys to file offsets
  • Trade-offs between recovery time, write amplification, and storage overhead

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