Ring Buffer for Sensor Messages With Per-Reader Overrun Detection

Last updated: November 29, 2026

Quick Overview

Implement a fixed-capacity ring buffer that one producer writes sensor messages into and several named consumers read from independently, where old messages are overwritten and each read reports how many messages that reader missed.

Aurora
Software Engineering Fundamentals
Software Engineer
Aurora
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Implement a fixed-capacity ring buffer that one producer writes sensor messages into and several named consumers read from independently, where old messages are overwritten and each read reports how many messages that reader missed.

Onboard autonomy code moves high-rate sensor data between components that run at different speeds, and a slow consumer must never block the producer. The interviewer checks indexing with monotonic sequence numbers, clear drop-oldest semantics, and whether you can talk about how this would look in C++ with real concurrency.

What the Interviewer Expects
  • Uses monotonic sequence numbers rather than wrapping head and tail indices
  • Lets each reader keep its own cursor
  • Detects and reports overrun when a reader falls more than capacity behind
  • Never blocks or slows the producer
  • Discusses thread safety and memory ordering for a lock-free version
Key Topics to Cover
Ring buffer
Sequence numbers
Producer consumer
Backpressure
Lock-free design
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 safe with one writer thread and many reader threads without a mutex?
  • How do you avoid copying large point clouds into the buffer?
  • What should the planner do when it learns it dropped lidar messages?
  • How would you test this for races?
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

publish(msg) always succeeds in O(1) and overwrites the oldest slot when full. subscribe(name) starts a reader at the current head (it sees only new messages). read(name, max_items) returns up t...

High-Level Design

Keep head as the total number of messages ever written. Slot for sequence s is s % capacity. The oldest sequence still in memory is max(0, head - capacity). A reader's cursor is a sequence num...


Submit Your Answer
Markdown supported

Related Questions