Try
↑ ↓ move↵ openesc close

Curriculum · Module 10, Design Walkthroughs

Lesson 3 · 7 topics · 37 min · Intermediate · 0/7 done

Design a chat system

Hold persistent connections on gateway servers and order messages with sequence numbers. Acknowledgements, resends and duplicate checks give delivery, and offline inboxes and presence fill the gaps.

What each topic covers

  • Chat needs open connections, a clear order, and delivery that survives a lost packet, a dead server and a phone that is off.
  • Size the connections and the message rate, then define the send call, the connection protocol and the stores.
  • Send messages through four gateways with loss, crashes and offline users, and compare showing on arrival with holding for order.
  • A resend fixes a lost message and breaks the order. A sequence number puts it right, at the price of a wait.
  • Gateways hold the open connections. A routing table says which gateway holds which user, and a crashed gateway sends its users back to reconnect.
  • Receipts are messages about messages. The offline inbox is the same sequence read later. Presence is a heartbeat that expires.
  • Three quick checks on order, duplicates and offline delivery, with the sources behind the lesson.

Topics

  1. 1A message that must arrive once, in order4 min
  2. 2Requirements, numbers, API and data model4 min
  3. 3Break the network and watch delivery8 min
  4. 4Loss, resends and the order they create6 min
  5. 5Gateways, connections and crashes6 min
  6. 6Receipts, offline inboxes and presence6 min
  7. 7The chat system in review3 min

Practise this lesson

8 interview questions on chat system, with worked answers and sources.

Practise these

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms