InfoWok

Design a Chat System: Media, Failure Modes and Follow-Ups (2026)

The core chat design is done and the interviewer keeps going: what if the gateway dies, how do photos and videos work, what about encryption, abuse, regions and cost? Three upload designs, a failure table, and eight short follow-up answers.

SK
Sukhveer Kaur
Published October 24, 2026
8 min read
Open in ChatGPT Open in Claude
Chat system follow-ups: a file upload goes straight to blob storage, a failure map shows each dead component covered by a fallback, and a short list of interview probes sits beside the line the log is the truthSoftware Architecture
CHAT SYSTEM FOLLOW-UPS
On this page +

The interviewer nods at your diagram and says: “Good. Now the gateway in the middle dies at peak. And someone sends a 200 MB video. And a regulator asks where the messages live.”

That is the second half of a chat round. The core design is the part you draw. These follow-ups show whether you have run something like it, and every answer can lean on one fact from the main lesson: the durable log is the truth, and everything faster is a bonus.

Intermediate25 min
Before you start
Remember from the main lesson

Why store a message before pushing it? Because the push can miss, and a message already in the durable log is picked up from the device’s cursor later. Every fallback below is a version of that sentence.

Key takeaways
  • Every component except the log can die without losing a message, because devices resume from a cursor.
  • Big files skip the chat path: upload to blob storage with a presigned URL and send a reference.
  • A rolling restart is a small reconnect storm, so drain gateways a few at a time.
  • Encryption, regions and retention are product trade-offs. Name the cost of each choice.
  • Say “judgement” out loud when an answer is design opinion rather than a vendor’s documented behaviour.
After this lesson you can

Answer the follow-ups that come after a chat design: walk each failure to its fallback, design media uploads in three tiers, and give a short trade-off answer on encryption, abuse, monitoring, deploys, cost and retention.

What Breaks, and What Saves You#

Start with the failures, because the main design was built around them. “Judgement” below means design opinion, not a vendor’s documented behaviour.

If this diesWhat happensWhy it is safe
A gatewayIts devices reconnect, with jitterCursors resume from the log
A conversation’s ownerSends to it pause until a standby takes overThe log holds the last seq; the standby continues from it
A log nodeReads and writes move to its copiesAck only after the durable write (assume a second zone)
The route tablePushes missDevices still find messages by gap detection and /sync
Pub/SubFast path stopsIt was never the source of truth
The push providerOffline devices are not wokenThey sync on next open
Predict first

Which row of the table is the only one where users notice, even though nothing is lost? Think about what the user sees, then check the first two rows.

Which Failures Do Users Feel?#

Two rows cost something visible. A dead gateway makes its devices wait through a reconnect, and a dead conversation owner pauses sends for that one conversation until the standby takes over. The other rows are invisible, because the log still holds every message. Say that distinction aloud: lost nothing, paused briefly is the honest claim, not “no impact”.

Words used here

A failover is the standby taking over. The second zone in the log row is an assumption: one copy of the log in another zone is what lets an ack mean “survives a zone loss”.

How Do Photos and Videos Work?#

Text messages are assumed at 200 bytes; a video can be megabytes. Keep big bytes off the chat path.

  • Works: Send the file through the chat connection. The client sends the bytes over its connection and the chat service stores them. Trade-off: Gateways are sized for many small messages. Large files tie up connections, and every reader pulls them back through the same servers.
  • Scales: Upload to blob storage, send a reference. The client asks the chat service for an upload slot and gets a presigned URL. It uploads straight to blob storage, then sends an ordinary message whose body is a reference: object key, type, size and a checksum. On Amazon S3, a presigned URL allows an upload without the client holding any storage credentials, and one made with the SDK can last up to 7 days. Trade-off: Two steps can half-fail: the upload finishes but no message goes out. Clean up unreferenced objects on a schedule.
  • Survives: Resumable uploads, thumbnails and a CDN. Phones lose signal mid-upload, so upload big files in parts and retry only the failed one. S3’s multipart upload retries just the interrupted parts and is recommended from 100 MB. A worker then makes a thumbnail, so a chat list never downloads the full file. Readers fetch media through a CDN. Trade-off: More moving parts. S3 keeps parts, and bills for them, until you complete or abort the upload, and suggests a lifecycle rule that aborts old incomplete uploads.

Why a Reference Message?#

The reference message is the point of the design. It goes through the same idempotent, numbered, stored path as any text, so media gets ordering, retries and catch-up for free. The file itself never touches a gateway.

Follow-ups Interviewers Add#

Short answers. “Judgement” marks design opinion, not a vendor’s behaviour.

QuestionAnswer in one breath
What if traffic grows 10x?200 gateways instead of 20 at the assumed 100,000 each; the log shards by conversation. The hot spot is one huge conversation: see the exercise in the main lesson.
Multi-region and data residency?Judgement: a home region and one owner per conversation, with the log copied asynchronously to a second region. State the cost: a region loss can drop the last acknowledged messages (diagram below). Residency rules decide which region may hold a conversation.
End-to-end encryption?The server routes ciphertext, and sequence numbers and cursors still work on opaque bytes. WhatsApp’s engineering post says the sender encrypts separately for each recipient device and groups use the Signal Protocol’s Sender Key scheme. MLS (RFC 9420) targets group key agreement for groups of two to thousands. Cost: no server-side search or moderation, and a new device needs history from an old one.
Spam and abuse?Judgement: rate limit per user and device (the 429 in the main lesson’s API), limit new accounts and group joins, check block lists before delivery, scan media in a worker, and let users report.
What do you monitor?Send-to-ack and send-to-push latency at the p99, ack success rate against an SLO, connections per gateway, reconnect rate, and how often gap repair fires. Alert on what users feel, not on CPU.
How do you deploy?A rolling gateway restart is a small reconnect storm, so drain a few at a time. To change storage, dual-write, backfill, compare reads, then switch.
What dominates cost?Judgement: idle connections (gateway count) and media downloads, not text storage. Move old messages to cold storage and serve media through the CDN.
How long do you keep data?A product and legal call. Delete-after-delivery (as WhatsApp describes) shrinks the log; keep-forever adds about 29 TB a year at the assumed load.

What Happens When a Whole Region Goes Dark?#

This is the multi-region row at full size. Assume each conversation has a home region (judgement), and the log is copied to a second region a moment after the ack. If the home region fails, the second region can take over from its copy, but any acknowledged message still inside the copy lag is gone from that copy.

Say the choice plainly: fail over now and accept losing the tail, or wait for the home region and accept an outage. Synchronous copies close the gap and add the cross-region round trip to every send.

Media has the same shape. A reference message can reach region B before its file does. S3 Replication Time Control copies most objects in seconds and 99.9 percent within 15 minutes, so a client should show a placeholder and retry the download instead of treating a missing object as an error. Residency rules add one more constraint: a conversation’s copy may only live in a region its members’ rules allow (judgement, not legal advice).

How Do You Answer a Follow-Up?#

Read the table for its pattern. Four rows (regions, encryption, retention, abuse) are trade-offs with a price, so answer with the choice and its cost. The other four (growth, monitoring, deploys, cost) are about operating what you drew, so answer with what you would watch or change first.

The most common way to waste a follow-up

Listing every technology you know instead of naming one choice and its cost. “Encryption: the server cannot search messages, so search moves to the device” beats a tour of key-exchange schemes.

A 45-Minute Plan#

Use this when the interviewer lets you pace the round. Follow-ups are the last slice, not the first.

text
 5 min  requirements, assumptions
 5 min  numbers and API
10 min  simple design and limits
20 min  two or three deep dives
 5 min  failures and follow-ups

If time is short, spend the last five minutes on the failure table, then offer one follow-up from the list above for the interviewer to pick.

Try It: A 250 MB Video on a Bad Connection#

Exercise · Resume a failed upload10 min

A user sends a 250 MB video from a phone with a weak signal. Assume the app uploads in 10 MB parts and the signal drops after 20 parts are done.

  1. How many parts are there, and how much must be re-sent if the upload restarts from scratch?
  2. How much must be re-sent with a resumable upload?
  3. The last part finishes, then the app crashes before the message is sent. What state is left, and how do you clean it up?
Hint

Divide the size by the part size. Then ask which object exists in storage and whether any message points at it.

One reasonable answer
text
250 MB / 10 MB = 25 parts
20 done, 5 left
restart: resend 250 MB
resume:  resend 50 MB

Restarting re-sends all 25 parts. A resumable upload re-sends only the 5 missing parts, a fifth of the data. If the app crashes after the upload, the object exists but no message points at it. Retry sends the message with the same client id, so a second attempt is safe. For users who never return, a scheduled sweep deletes objects that nothing references after a set age. Part sizes here are assumptions, and S3 recommends multipart from 100 MB.

In an interview

After the core design, expect one of: “What if the gateway dies?”, “How do you send a video?”, “Is it end-to-end encrypted?”. Start each answer with the one choice, then its cost, then a number if you have one.

Check Yourself#

Check yourself5 questions · answer, then open
1.A log node dies. Why is no acknowledged message lost?

The ack is sent only after the durable write, and the log has a copy in a second zone. Reads and writes move to the copy.

2.Why send a reference in the message instead of the video itself?

Gateways are sized for many small messages. The file goes straight to blob storage, and the message that points at it is stored, ordered and retried like any text message.

3.A conversation's owner dies. What do users see, and what does not break?

Sends to that one conversation pause until a standby takes over and continues from the last sequence number in the log. Other conversations and all stored messages are unaffected.

4.Region A fails with its copy two messages behind. What are the two choices, and what does each cost?

Fail over to region B and lose the two acknowledged messages the copy never received, or wait for region A and accept the outage. Synchronous copying avoids the loss but adds a cross-region round trip to every send.

5.What changes if the product adds end-to-end encryption?

The server routes ciphertext only, so it cannot search or moderate message text, and a new device needs history from an old one. Search moves to the device.

Learning tip

Tomorrow, cover the right-hand column of the failure table and say what covers each failure. Then name the one failure that users can feel.

In One Picture#

text
Failures
  all end at the durable log
Media
  presigned upload + reference
Follow-ups
  one choice, then its cost
Deploys
  drain a few gateways at a time
Plan
  failures get the last 5 minutes
Rule
  the log is the truth

Conclusion#

The 60-second follow-up answer: nothing but the log is the source of truth, so any gateway, route table, Pub/Sub or push failure costs a reconnect at most. Media goes to blob storage with a presigned URL and travels as a reference message. For encryption, regions and retention, name the choice and its price.

Which follow-up has caught you out before? Tell us in the comments.

Where to go from here

Frequently asked questions

How should a chat app send photos and videos? +
Keep the bytes off the chat path. The client asks the chat service for an upload slot, uploads straight to blob storage with a presigned URL, then sends an ordinary message whose body is a reference to the object. Amazon S3 documents that a presigned URL lets someone upload without storage credentials of their own.
What happens to a chat system when a gateway server dies? +
Its devices lose their connections and reconnect, ideally after a random delay so they do not all arrive at once. Each device resumes from its cursor, so nothing is lost, because every message was stored in the durable log before it was pushed.
Can a chat server read end-to-end encrypted messages? +
No, it routes ciphertext. WhatsApp's engineering post describes the sender encrypting separately for each recipient device, with the Signal Protocol's Sender Key scheme for groups. The cost is no server-side search or moderation, and a new device needs its history from an old one.
What should you monitor in a chat system? +
Alert on what users feel: send-to-ack and send-to-push latency at the p99, the share of sends acknowledged within a target, connections per gateway, reconnect rate, and how often gap repair fires. CPU alone says little about message delivery.

References

  1. Amazon S3 User Guide, Uploading objects with presigned URLs
  2. Amazon S3 User Guide, Multipart upload overview
  3. Meta Engineering, WhatsApp multi-device (per-device encryption, Sender Key groups)
  4. Amazon S3 User Guide, Replication Time Control (S3 RTC)
  5. RFC 9420, The Messaging Layer Security (MLS) Protocol
Written by
Sukhveer Kaur
Sukhveer KaurSoftware Developer & AI Engineer

Sukhveer is a software developer specialising in AI systems and backend engineering. She has hands-on experience designing agentic AI applications, working with large language model pipelines, autonomous agent frameworks, and cloud-native services in Java and Python. At InfoWok, she bridges the gap between cutting-edge AI research and practical implementation — helping developers understand and apply emerging technologies through clear, experience-backed writing.

New AI engineering guides, the day they ship

Real Python, production depth. No digest spam.

Comments