Metro Camera Message Queue: Format Versioning, Large Video Payloads and Message Loss
Quick Overview
A messaging design question for metro traffic cameras that send data through a message queue. It covers versioning the message format, binary serialization, timestamps and checksums, moving large video payloads, and keeping messages from being lost when consumers fail repeatedly.
Metro Camera Message Queue: Format Versioning, Large Video Payloads and Message Loss
Company: Amazon
Role: Software Engineer
Category: System Design
Difficulty: hard
Interview Round: Technical Screen
A metro (subway) system has traffic cameras that send their output to back-end services through a message queue. Design the messaging layer. The scenario raises three concerns: the message format, large messages and lost messages.
### Clarifying Questions
- What do the cameras send: event records, still images, video clips, or a mix? How large is each kind, and how often is it sent?
- Which services consume the messages, and are they written in different languages?
- How quickly does a message lose its value, for example a live traffic alert compared with footage kept as evidence?
- Can a camera buffer data locally when its network link or the queue is down?
- Is processing the same message twice harmful?
### Part 1: Message format
Define the message format. The scenario asks about versioning the format, binary serialization, and including a timestamp and a checksum. How do you choose a serialization format, and how do you change the format later without breaking producers or consumers?
```hint Start from compatibility
Decide who must keep reading which messages after the format changes, given that cameras and consumers are upgraded at different times.
```
#### What This Part Should Cover
- The choice of serialization format based on use and compatibility needs.
- Versioning and schema evolution rules.
- What the timestamp means and what the checksum protects.
### Part 2: Large messages
Some payloads, such as video, are far larger than a message queue handles well. How do you move them?
```hint What must travel through the queue
Ask whether consumers need the bytes inside the message or only a way to find and verify them.
```
#### What This Part Should Cover
- Keeping large payloads out of the queue.
- Chunking or streaming when the payload cannot leave the message path.
- Ordering and cleanup between stored objects and the messages that point to them.
### Part 3: Lost messages
Messages are being lost. Design the path from camera to consumer so that an accepted message is not lost, and decide what happens to messages that keep failing.
```hint Trace every hand-off
Find each point where a message changes hands and decide who is responsible for it until the next party confirms receipt.
```
#### What This Part Should Cover
- Acknowledgements and persistence at each hop.
- Retries for temporary failures and a dead-letter path for repeated failures.
- Expiry, monitoring and retention.
### What a Strong Answer Covers
- Format choices tied to the consumers and to how producers and consumers are upgraded.
- Handling of large media that keeps the queue fast.
- At-least-once delivery end to end, with idempotent consumers.
- A dead-letter queue run as an operational system with persistence, alerts and a retention policy.
### Follow-up Questions
- A firmware update changes the message schema on half the cameras. How do consumers cope during the rollout?
- A consumer bug sends 10,000 messages to the dead-letter queue. How do you replay them safely after the fix?
- How do you detect that a camera has stopped sending when nothing reports an error?
- Camera clocks drift. How does that affect timestamps and ordering?
Overview: A messaging design question for metro traffic cameras that send data through a message queue. It covers versioning the message format, binary serialization, timestamps and checksums, moving large video payloads, and keeping messages from being lost when consumers fail repeatedly.
A metro (subway) system has traffic cameras that send their output to back-end services through a message queue. Design the messaging layer. The scenario raises three concerns: the message format, large messages and lost messages.
Clarifying Questions Guidance
What do the cameras send: event records, still images, video clips, or a mix? How large is each kind, and how often is it sent?
Which services consume the messages, and are they written in different languages?
How quickly does a message lose its value, for example a live traffic alert compared with footage kept as evidence?
Can a camera buffer data locally when its network link or the queue is down?
Is processing the same message twice harmful?
Part 1: Message format
Define the message format. The scenario asks about versioning the format, binary serialization, and including a timestamp and a checksum. How do you choose a serialization format, and how do you change the format later without breaking producers or consumers?
What This Part Should Cover Guidance
The choice of serialization format based on use and compatibility needs.
Versioning and schema evolution rules.
What the timestamp means and what the checksum protects.
Part 2: Large messages
Some payloads, such as video, are far larger than a message queue handles well. How do you move them?
What This Part Should Cover Guidance
Keeping large payloads out of the queue.
Chunking or streaming when the payload cannot leave the message path.
Ordering and cleanup between stored objects and the messages that point to them.
Part 3: Lost messages
Messages are being lost. Design the path from camera to consumer so that an accepted message is not lost, and decide what happens to messages that keep failing.
What This Part Should Cover Guidance
Acknowledgements and persistence at each hop.
Retries for temporary failures and a dead-letter path for repeated failures.
Expiry, monitoring and retention.
What a Strong Answer Covers Guidance
Format choices tied to the consumers and to how producers and consumers are upgraded.
Handling of large media that keeps the queue fast.
At-least-once delivery end to end, with idempotent consumers.
A dead-letter queue run as an operational system with persistence, alerts and a retention policy.
Follow-up Questions Guidance
A firmware update changes the message schema on half the cameras. How do consumers cope during the rollout?
A consumer bug sends 10,000 messages to the dead-letter queue. How do you replay them safely after the fix?
How do you detect that a camera has stopped sending when nothing reports an error?
Camera clocks drift. How does that affect timestamps and ordering?