Detect and Recover Sequence Gaps in a Multicast Market Data Feed
Last updated: November 29, 2026
Quick Overview
Write the sequencing layer of a feed handler: packets carry sequence numbers, may arrive out of order or duplicated from redundant A/B lines, and the handler must release messages strictly in order, request retransmission for gaps, and fall back to a snapshot when a gap cannot be filled.
Millennium
November 29, 20260
0
0 solved
Write the sequencing layer of a feed handler: packets carry sequence numbers, may arrive out of order or duplicated from redundant A/B lines, and the handler must release messages strictly in order, request retransmission for gaps, and fall back to a snapshot when a gap cannot be filled.
Millennium's trading and research systems depend on normalized exchange data, and feed handlers that silently drop a packet corrupt the order book for every downstream pod. The interviewer checks sequencing logic, buffering limits and whether you understand A/B line arbitration and snapshot recovery.
What the Interviewer Expects
- Releases messages strictly in sequence order
- Drops duplicates from the redundant line cheaply
- Buffers out-of-order packets and requests the missing range once
- Bounds the buffer and escalates to a snapshot plus replay when recovery fails
- Explains why the book must be marked stale while a gap is open
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you choose the buffer size and a gap timeout?
- What happens to the book while waiting for retransmission, and what do you tell consumers?
- How would you do this with zero allocation in C++?
- How do you merge a snapshot that is itself at some sequence number with buffered incrementals?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
on_packet(seq, msg) returns messages that are now deliverable in order. Duplicates (seq already delivered or buffered) are ignored. The first gap triggers one retransmit request for the missing rang...
High-Level Design
Track expected, the next sequence to deliver. Packets equal to expected are delivered and then the buffer is drained while it holds the next sequence. Packets ahead of expected are buffered. Pac...