Skip to content

← Interview Arena

Design a chat service

Design a chat service

The Arena needs JavaScript to run an interview.

Design a chat service: people send short messages to one person or to a group, and see them arrive at once on every device they have open. The messages of a conversation must appear in the same order for everyone and must not be lost when the recipient is offline. Work through the stages in order, as you would on a whiteboard: requirements, numbers, architecture, scaling, consistency, reliability, failure and trade-offs.

Key facts

Daily users
10 million
Messages
30 per user per day
Mix
90 % one-to-one, 10 % to a group of 20 members
Peak
Assume the busiest moment is 3 times the average, with 20 % of the daily users connected and 30 % of the recipients offline when a message arrives
Message size
About 200 bytes
Connections
About 50,000 open connections per gateway server, and a heartbeat every 30 seconds from each connection
One database
A write takes about 5 ms, 4 at a time

Constraints

  • Photos and videos, calls, search and end-to-end encryption are out of scope unless you choose to cover them.
  • The service runs in one region.
  • The Architecture Builder runs your design at the peak, 10,000 messages per second; a request in it is one message sent, and 10 % of its requests are reads (an exercise setting).
  • The figures are illustrative targets for this exercise, not measurements of a real service.

Suggested time per stage

  1. Requirements05:00
  2. Estimation06:00
  3. Architecture10:00
  4. Scaling06:00
  5. Consistency04:00
  6. Reliability04:00
  7. Failure scenarios05:00
  8. Trade-offs05:00
Mode

You can pause the clock, nothing is locked, and running out of time is only shown.

The clock cannot be paused. At zero, the stage you are on is locked as written and the stages after it score zero.

Length

Built by GhaziAlibi.

© ShardCraft. All rights reserved.