Build a Conflating Bounded Queue for Market Data Updates

Last updated: November 29, 2026

Quick Overview

Implement a thread-safe bounded queue between market data producer threads and a slower consumer, where a new update for a symbol that is already waiting replaces the old one instead of taking a new slot.

Akuna Capital
Software Engineering Fundamentals
Software Engineer
Akuna Capital
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Hard

0

0

0 solved


Implement a thread-safe bounded queue between market data producer threads and a slower consumer, where a new update for a symbol that is already waiting replaces the old one instead of taking a new slot.

Akuna Capital's market data and quoting stack must stay current under bursts, and a consumer that falls behind is worse off processing stale ticks in order than skipping to the latest. The interviewer checks correct locking with condition variables, conflation semantics, shutdown handling, and how you would do the same in lock-free C++.

What the Interviewer Expects
  • Explain why conflation fits market data (only latest state matters per symbol)
  • Use one lock with two condition variables and while-loop waits
  • Keep fairness: symbols are served in first-arrival order
  • Support timeouts and a clean close
  • Discuss lock-free SPSC ring buffers and false sharing for the C++ version
Key Topics to Cover
concurrency
condition variables
conflation
backpressure
market data
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you make this lock-free for a single producer and single consumer?
  • Which updates must never be conflated (trades vs quotes)?
  • How do you measure and alert on consumer lag?
  • What is false sharing and how does it affect a ring buffer?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

put(symbol, update) from many threads, get() from a consumer. Capacity bounds the number of distinct symbols waiting. If the symbol is already queued, overwrite its update in place (no new slot, k...

High-Level Design

A deque holds symbols in arrival order, each at most once, and a dict holds the latest update per waiting symbol. One mutex protects both. not_empty and not_full condition variables share that mut...


Submit Your Answer
Markdown supported

Related Questions