Slack / Discord
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Design Slack / Discord: the 60-second story

    Design Slack / Discord

    Last over of an IPL final: 400,000 people online in one server.

    Every line must reach every open screen within a second, stay for ever, and be searchable years later.

    50M/s

    deliveries a second from one server

    One server with a million people online carries 50 messages a second during a launch. Push each to every session, and that’s 40× the whole platform’s average.

    Mailbox or room?

    Bad: A copy per member

    WhatsApp-style, an audience of 25 costs 30 TB a day.

    Good: Store once, push live

    1.2 TB a day. Offline members get no push; they read history later.

    A million online. The server’s owner sends 67 copies, not a million.

    Relays of 15,000 sessions do the sends and permission checks. Nine in ten sessions are passive, with no message bodies until you click in.

    @everyone to 10 million members: a counter each means 10 million writes.

    The trick

    Compare two IDs, last read vs last message. Count only people named; @everyone is counted at read time. One write.

    Thousands ask for the same page. The database sees one query.

    Every request for a channel is hashed to one data service. The first reads the database; the rest wait for its answer.

    A train enters a tunnel. Resume after event 4182; don’t reload.

    Every event carries a sequence number. The session outlives its socket for a few minutes, buffers what you miss, and replays it on Resume.

    When a whole region reconnects at once

    1. Jitter heartbeats and reconnect delays
    2. Drain gateways over minutes, not seconds
    3. Rate-limit full identifies, the expensive kind
    4. Send a slim start-up snapshot; load the rest lazily

    Remember

    A room, not a mailbox. Store each message once by channel and time bucket. Push only to active sessions that may see it, through relays for giants. Unread compares two IDs.