KatInterview

Design a Self-Destructing Broadcast Messaging System

System DesignModel answer
HardModel answerSystem Designmessagingdistributed-systemsfan-out

Last updated

Design a messaging service where one sender dispatches a message to many recipients, each of whom can read it exactly once before it disappears permanently.

Scenario

You are designing a messaging feature for a mobile-first platform. The feature works like this: a sender composes a message, picks a list of recipients, and hits send. Each recipient gets their own private copy. The moment a recipient reads the message, that copy is gone — permanently and irreversibly — for that person. Other recipients are completely unaffected and can still read their own copies.

This is not a group chat. There is no shared thread, no read receipts visible to other recipients, and no way to retrieve content after it has been opened.

What to design

Cover all of the following areas. Spend about the same depth on each rather than over-indexing on any single layer.

API surface

  • What endpoints exist and what do they do?
  • How do you prevent accidental double-reads from caches, prefetchers, or HTTP retries?

Data model

  • How do you represent a message body versus a per-recipient delivery?
  • How do you ensure that "permanently unavailable" holds even for backups and cold storage, not just the primary database?

High-level architecture

  • Which services exist, and how do they communicate?
  • How does a newly created message reach each recipient's inbox?

Fan-out strategy

  • Synchronous or asynchronous? At what threshold?
  • How do you keep fan-out idempotent so worker retries are safe?

Read-once enforcement

  • What write pattern guarantees exactly one successful open per recipient?
  • What happens if the server commits the open but the response never reaches the client? How do you handle that edge case without silently destroying the message?

Deletion and retention

  • When and how is content removed?
  • How do you handle unread messages that were never opened?

Scaling and partitioning

  • What are the natural partition keys?
  • Where are the hot spots, and how do you mitigate them?

Failure handling and consistency trade-offs

  • Where do you accept eventual consistency, and where do you need stronger guarantees?
  • What breaks under network partition, and what is your recovery path?

Constraints and assumptions to state upfront

Clarify these before designing — the interviewer may adjust them:

  • Up to 1,000 recipients per send; larger batches take an async path
  • Text content up to ~4 KB; media (images, video) up to ~25 MB stored in a blob store
  • A user may own multiple devices, but only the first open wins across all of them
  • Unread messages expire after 30 days
  • The sender can see per-recipient delivery state (sent, delivered, opened) but cannot re-read the content
  • "Permanently unavailable" means unreadable at the application layer even if raw ciphertext bytes survive in a backup

What a strong answer looks like

A strong response opens with a short back-of-envelope sizing exercise that motivates architectural choices, works through each section above in order, calls out at least two non-obvious trade-offs (the response-loss problem on open, crypto-shredding vs. hard delete, etc.), and is concrete enough that an engineer could start implementing from the description.

Hints

Hint 1

Think carefully about which API verb you use for the open action and why a plain GET is dangerous here — what infrastructure automatically issues GETs that you cannot control?

Hint 2

The hardest correctness problem is not delivery, it is what happens when the server successfully commits the read-once transition but the network drops before the client receives the response. Walk through that failure scenario before you finalize your open endpoint design.

Hint 3

Deleting a row from the primary database does not make content 'permanently unavailable' if ciphertext copies live in read replicas, backups, or a CDN. Think about a key-management approach that makes surviving ciphertext useless for a specific recipient without touching every copy.