← Questions
Design a replay system for publish-subscribe
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A system design interview question asked in Google's first round (coding), last asked Mar 2026. It tests pub/sub, messaging and storage.
Publishers send messages to topics, and subscribers receive them through a publish-subscribe system. Design a replay feature: a subscriber can ask to receive past messages again, from a chosen point (a time or a position), for example after a bug in its own processing. Replay must not slow down live delivery for everyone else.
Requirements
- Functional: publish to a topic; subscribers receive new messages live; a subscriber can start a replay from a timestamp or an offset and receive messages in order, then catch up to live; several subscribers can replay at once, independently; retention is configurable per topic.
- Non-functional: high publish throughput (say a million messages per second across topics); low live latency; retention of days to weeks; replayed messages in the same order as the original; at-least-once delivery with a clear story for duplicates.
Clarifying questions
- How far back must replay reach, and how much data is that?
- Is replay by time, by position, or both?
- Does a subscriber replay alone, or does a whole subscriber group rewind?
- Must ordering hold across a whole topic, or only within a key or partition?
- During replay, does the subscriber also get live messages, or does replay run first and then switch to live?
What a strong answer covers
- Storage as an append-only log per topic partition, with offsets; retention by time or size, with old segments moved to cheaper storage.
- A time index (timestamp to offset) per segment so a replay by time finds its start quickly.
- Subscriber position tracked as a committed offset per partition, stored in the system; a replay is a new cursor starting at an older offset.
- Isolation of replay from live traffic: live reads hit the page cache or memory at the tail, replay reads come from disk or object storage through separate threads, quotas or dedicated replay brokers.
- Catching up: replay reads forward until it reaches the live tail, then switches without a gap or duplicate, by handing over at an exact offset.
- Delivery semantics: at-least-once with consumer-side idempotency keys, and what replay means for exactly-once.
- Retention and compaction trade-offs, and what happens when a requested start point has already been deleted.
Follow-ups
- A subscriber replays a week of a hot topic. How do you keep it from overloading the brokers?
- Replay only messages matching a filter (one customer's events).
- Messages contain personal data that must be deleted on request. How does that interact with replay?
- Replay across regions after a regional outage.
Where it's asked
- Google · First round: coding · Last asked Mar 202645 min · Coding in a Google Doc, no syntax highlighting or autocomplete · No AI
What it tests
pub/sub · messaging · storage
No official answer yet. Draw yours on the right; publish it and it shows under Community.
Nothing published yet. Publish your canvas and it shows here for others to open and remix.
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing
