Preparing your design workspace

Loading the problem and your latest saved attempt…

WhatNot: One-to-One Chat Service

Design buyer-seller direct messages for a web marketplace: fast delivery to every open browser, the same history and read state on all of a user's browsers, and an email or SMS notice when the receiver is offline.

Problem statement

This is WhatNot's version of One-to-One Chat Service, built from WhatNot's interview reports.

Design direct messages for an online marketplace. A buyer can message a seller, and a seller can message a buyer. People use the marketplace in a web browser only. A new message should reach the other person fast. When the other person has no browser open, they should hear about it by email or text message (SMS).

Someone signed in on two computers must see the same conversations on both.

For this exercise, assume:

Conversations. A conversation always has exactly two people: one buyer and one seller. There is at most one conversation per pair, and either person can start it. Messages are plain text up to 2,000 characters.

Browsers. A user can be signed in on up to 5 browsers at once, for example a laptop and a work computer. Every browser shows the same conversations, the same messages in the same order, and the same read state. Signing in on a new browser shows the full history; nothing is kept only in one browser.

Delivery. The sender sees "sent" only after the message is saved. Each open browser of the receiver should show it within 1 second. A browser can lose its connection at any moment. When it reconnects, it must catch up on everything it missed, with no gaps and no duplicates.

Offline notices. A user counts as offline when none of their browsers is connected. When a message arrives for an offline user, they get a notice by the channel they chose, email or SMS, within about 2 minutes. To avoid spam, a user gets at most one notice per conversation every 15 minutes, and no notice for a message they already read on another browser. Email and SMS go through outside providers, which may be slow or fail.

Inbox. Each user sees a list of their conversations, newest activity first, with an unread count for each. A busy seller can have thousands of conversations.

Out of scope: group chats, images and files, mobile apps and phone push notifications, message search, editing or deleting messages, blocking and spam filtering, typing indicators, showing whether the other person is online, end-to-end encryption, and running in more than one region.

What to build

  1. A buyer or seller can start or open their one conversation with the other person and send a text message. The sender sees "sent" only after it is saved, and a retried send never shows up twice.
  2. Every open browser of the receiver, and the sender's other browsers, show a new message within about 1 second, in the same order everywhere.
  3. Any browser a user signs into or reconnects from shows the full conversation list and history with no gaps, and reading a conversation on one browser marks it read on the others.
  4. A user with no browser connected gets an email or SMS notice, by their chosen channel, about a new unread message within about 2 minutes, at most once per conversation every 15 minutes.

At scale

  • For this exercise, assume about 10 million people use messages each day, and at peak they send about 10,000 messages per second.
  • For this exercise, assume about 3 million browsers keep a live connection open at peak, and each user has at most 5.
  • For this exercise, assume saved messages are kept for at least 2 years, and a message must never be lost once its sender has seen "sent".