Day 28 Exercises

Real-Time Collaboration Design

Apply WebSocket routing, presence systems, and message fan-out to enterprise messaging architecture.

Exercise 1🟡 Easy15 min
Presence System Design
Slack shows green dot (online), yellow clock (away), and grey dot (offline) for each user. With 20 million active users, designing an accurate, scalable presence system is non-trivial.

Tasks

  • How does a client signal that it's online? What's the heartbeat interval?
  • Design the Redis schema for presence state.
  • Why is Redis TTL a better approach than a database "last_seen" column?
  • How do you aggregate presence across multiple devices (phone + laptop)?
Your Notes
Exercise 2🔴 Medium20 min
Channel Message Fan-Out
A message is sent to #engineering (8,000 members, 3,000 currently online). Design the delivery path that gets the message to all 3,000 online members within 200ms.

Tasks

  • Design the fan-out pipeline from message send to delivery.
  • How do you find which gateway server holds each online member's WebSocket?
  • What's the parallelism strategy to reach 3,000 connections within 200ms?
  • How do offline members receive the message when they reconnect?
Your Notes
Exercise 3🔴 Medium25 min
Message Search Architecture
Slack's search must find any message sent in the last 12 months across all channels a user has access to. With 26 billion messages indexed, searches must return in under 500ms.

Tasks

  • Why can't you use a SQL LIKE query for full-text search at this scale?
  • Design the Elasticsearch index schema for Slack messages.
  • How do you enforce channel access control (user should only see messages from channels they're in)?
  • How do you handle search for very common words like "the" or "and"?
Your Notes
Exercise 4🔥 Hard35 min
Slack Connect (Cross-Workspace Messaging)
Slack Connect allows users from different organizations to message each other. Alice (acme.slack.com) messages Bob (startup.slack.com). Design the cross-workspace message routing.

Tasks

  • How does Alice's message get routed to Bob's workspace infrastructure?
  • How do you handle access control between workspaces (Bob can't see Alice's private channels)?
  • Design the data ownership model: who stores the message?
  • How do you handle the case where Startup's Slack instance goes down? Does Alice's message get lost?
Your Notes