PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/System Design/Databricks

Design a thread-safe bounded queue

Last updated: Apr 19, 2026

Quick Overview

This question evaluates skills in concurrent programming, synchronization primitives, and designing thread-safe bounded data structures that support blocking operations with timeouts, fairness, and backpressure.

  • hard
  • Databricks
  • System Design
  • Software Engineer

Design a thread-safe bounded queue

Company: Databricks

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: HR Screen

Design and implement a thread-safe bounded queue supporting multiple producers and consumers. Provide blocking enqueue/dequeue with timeouts, avoid deadlocks and starvation, and ensure fairness under contention. Discuss your locking strategy (mutexes vs. lock-free), condition/signaling mechanisms, backpressure handling when the queue is full, and how you'd test correctness and performance. Analyze time and space complexity.

Quick Answer: This question evaluates skills in concurrent programming, synchronization primitives, and designing thread-safe bounded data structures that support blocking operations with timeouts, fairness, and backpressure.

Related Interview Questions

  • Design a Book Price Aggregator - Databricks (medium)
  • Design a stock order manager - Databricks (medium)
  • Design an Online Bookstore - Databricks (hard)
  • Design a Hierarchical File System - Databricks (hard)
  • Design a Visa-like payment processing system - Databricks (hard)
Databricks logo
Databricks
Sep 6, 2025, 12:00 AM
Software Engineer
HR Screen
System Design
19
0

Design a Thread-Safe Bounded MPMC Queue with Timeouts and Fairness

Context

You are building a reusable, in-memory, bounded queue that supports multiple producers and multiple consumers (MPMC). Operations must block with timeouts, avoid deadlocks and starvation, and be fair under contention.

Requirements

  • Provide a bounded queue with capacity N.
  • Support blocking operations with timeouts:
    1. enqueue(item, deadline) → true on success; false on timeout.
    2. dequeue(deadline) → item on success; timeout error/null on timeout.
  • Ensure:
    • Thread safety with many producers and consumers.
    • No deadlocks.
    • No starvation; enforce fairness under contention.
    • Backpressure when the queue is full.
  • Discuss:
    • Locking strategy (mutexes vs. lock-free).
    • Condition/signaling mechanisms.
    • Backpressure policy.
    • Testing strategy for correctness and performance.
    • Time and space complexity.

Assumptions

  • Language/runtime provides mutexes, condition variables, and monotonic clocks for timeouts.
  • Capacity N ≥ 1; item copy/move is safe and does not invoke user code while locks are held.
  • If needed, define a close()/shutdown() method to wake waiters and terminate gracefully.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More Databricks•More Software Engineer•Databricks Software Engineer•Databricks System Design•Software Engineer System Design
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.