PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Software Engineering Fundamentals/Netflix

Design a thread-safe key-value store

Last updated: Mar 29, 2026

Quick Overview

This question evaluates knowledge of concurrent programming and thread-safety, including the choice of in-memory data structures for a key–value store and synchronization techniques that ensure atomic put/get/delete operations without internal corruption.

  • medium
  • Netflix
  • Software Engineering Fundamentals
  • Software Engineer

Design a thread-safe key-value store

Company: Netflix

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

You are working on infrastructure for an AI platform. Inside a single process, many worker threads need to share a simple in-memory key–value store; any thread can concurrently read, write, or delete keys. Design and discuss a thread-safe key–value store class with the following requirements: - **Environment:** Single process, multiple threads (no multi-machine / distributed concerns). - **Operations:** - `put(key, value)`: insert or overwrite the value for `key`. - `get(key)`: return the current value for `key`, or `null` / `None` if absent. - `delete(key)`: remove `key` if it exists. - **Correctness:** - Operations must be safe under arbitrary concurrent usage (no lost updates, no corrupted internal state). - Each operation should appear atomic to callers. - **Performance:** - Aim to minimize lock contention; a single global lock is allowed but you should consider and discuss alternatives. - **Data model:** - Keys can be assumed to be strings; values can be arbitrary objects (or generics). Answer the following sub-questions: 1. What internal data structure(s) would you use to store the key–value pairs, and why? 2. What synchronization strategy would you apply (e.g., a single global lock, per-bucket or per-key locks, lock striping, or a language-provided concurrent map)? Discuss the trade-offs. 3. Suppose you must implement this in a language **without** a built-in concurrent map (for example, Python with a normal `dict`). How would you implement your chosen synchronization strategy there? Describe or sketch the implementation of `put`, `get`, and `delete`. 4. How would you test / validate that your implementation is correct and free from race conditions? Consider unit tests, concurrent stress tests, and any tools or techniques you might use. 5. If this store were to be used in production, what additional concerns would you consider (e.g., validation of inputs, logging, metrics, capacity limits, performance tuning, or persistence)?

Quick Answer: This question evaluates knowledge of concurrent programming and thread-safety, including the choice of in-memory data structures for a key–value store and synchronization techniques that ensure atomic put/get/delete operations without internal corruption.

Related Interview Questions

  • Model Direct-Sold DSP Orders - Netflix
  • Design demand-side ads relational tables - Netflix (hard)
  • Design a concurrent latency percentile tracker - Netflix (hard)
  • Explain concurrency and reliability tradeoffs - Netflix (hard)
Netflix logo
Netflix
Nov 10, 2025, 12:00 AM
Software Engineer
Technical Screen
Software Engineering Fundamentals
30
0

You are working on infrastructure for an AI platform. Inside a single process, many worker threads need to share a simple in-memory key–value store; any thread can concurrently read, write, or delete keys.

Design and discuss a thread-safe key–value store class with the following requirements:

  • Environment: Single process, multiple threads (no multi-machine / distributed concerns).
  • Operations:
    • put(key, value) : insert or overwrite the value for key .
    • get(key) : return the current value for key , or null / None if absent.
    • delete(key) : remove key if it exists.
  • Correctness:
    • Operations must be safe under arbitrary concurrent usage (no lost updates, no corrupted internal state).
    • Each operation should appear atomic to callers.
  • Performance:
    • Aim to minimize lock contention; a single global lock is allowed but you should consider and discuss alternatives.
  • Data model:
    • Keys can be assumed to be strings; values can be arbitrary objects (or generics).

Answer the following sub-questions:

  1. What internal data structure(s) would you use to store the key–value pairs, and why?
  2. What synchronization strategy would you apply (e.g., a single global lock, per-bucket or per-key locks, lock striping, or a language-provided concurrent map)? Discuss the trade-offs.
  3. Suppose you must implement this in a language without a built-in concurrent map (for example, Python with a normal dict ). How would you implement your chosen synchronization strategy there? Describe or sketch the implementation of put , get , and delete .
  4. How would you test / validate that your implementation is correct and free from race conditions? Consider unit tests, concurrent stress tests, and any tools or techniques you might use.
  5. If this store were to be used in production, what additional concerns would you consider (e.g., validation of inputs, logging, metrics, capacity limits, performance tuning, or persistence)?

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Netflix•More Software Engineer•Netflix Software Engineer•Netflix Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL 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.