Preparing your design workspace

Loading the problem and your latest saved attempt…

One-to-One Chat Service

Design a durable web messaging service for private two-person conversations, including conversation discovery, ordered storage, replayable delivery, replica-aware reads, burst handling, and offline recovery.

Problem statement

For this exercise, assume authenticated users exchange text messages in private conversations that always have exactly two participants.

The product serves 100 million daily active users through web clients only; mobile push, group chat, media attachments, user-visible presence, typing indicators, end-to-end encryption key management, and moderation are out of scope.

An internal connection directory may track which gateway currently holds a user's web connection. A sender receives success only after the message is durably persisted, an online recipient should see it quickly, and an offline user should discover every conversation they participate in and catch up after reconnecting.

Each conversation exposes one stable message order, retries must not create duplicate visible messages, and acknowledged messages must survive ordinary service failures.

For capacity planning, assume each daily active user sends 100 messages per day, about 116,000 writes per second on average before an explicit peak factor. Design a user-to-conversation index rather than scanning message shards when a user loads their conversation list.

Historical pagination and offline catch-up may use a bounded-lag replica, but an online gap repair for a newly committed message must use a sufficiently fresh authoritative path.

During a sudden traffic spike, preserve durable sends first, shed or defer historical reads explicitly, and explain exactly which load a cache removes without letting it become the source of truth.

Choose and justify a durable event path. Explain how Kafka partitioning, producer retries, replay, consumer groups, and consumer latency could implement it, and compare that design with Redis Pub/Sub or Redis Streams for low-latency routing and recovery.

A different main log is acceptable when it provides the same ordering, retention, replay, and consumer-coordination guarantees. Design the components, connections, request and event flows, storage and index boundaries, cache behavior, read consistency, and failure recovery.

For the cross-region follow-up, assume the two participants may connect through different regions.

Extend the same private-message journey across those regions: explain conversation routing and partition placement, live event delivery and replay, database growth, and what happens when a region or inter-region link fails. Preserve one conversation order, retry identity, authorization, and explicit read freshness.

State your replication and acknowledgement policy, which acknowledged data survives a regional loss, and when writes must pause instead of allowing conflicting owners.

The existing latency and single-zone durability targets remain the single-region baseline; for this extension state the added network budget and the recovery guarantees your design can actually meet.

Region count, placement, replication strategy, failover time and any additional numerical target are design choices, not prescribed product facts.

What to build

  1. A participant can idempotently send a text message to a private conversation and receive a stable message identifier plus durable acknowledgement.
  2. An online participant receives newly committed messages for each conversation with low latency and without duplicate visible delivery.
  3. A participant can efficiently list every private conversation they belong to, page its ordered history, and reconnect from a durable cursor to recover messages missed while offline without scanning all message shards.
  4. Deliver committed messages through a durable replayable event path with bounded consumer latency, explain how Kafka could implement that path, and compare when Redis Pub/Sub or Redis Streams would or would not satisfy the same recovery contract.

At scale

  • Source-backed scale: support 100 million daily active users through web clients, with one-to-one text conversations and offline message recovery.
  • For this exercise, assume each daily active user sends 100 messages per day, about 116,000 message writes per second on average before an explicit peak multiplier and storage forecast.
  • Target a p95 durable send acknowledgement below 300 milliseconds and online delivery below one second; retain history for at least one year and survive a single-zone failure.
  • Historical reads and offline catch-up may use bounded-lag replicas, but fresh online gap repair must use an authoritative path; traffic spikes may degrade historical loading before durable sends.