Live comments
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.

    Layer 3 · Go deeper · 11 min

    Go deeper

    Size it, build it, then make the calls an interviewer will push you on.

    Back of the envelope

    Size it up

    Tap through each step of the arithmetic.

    How many gateway servers hold the connections?

      What does delivering every comment to every viewer cost?

        What if each viewer gets one frame a second instead?

          How many reaction requests a second at a big moment?

            Build-up · 5 steps

            Build the high-level design

            One functional requirement at a time, ending with a design that works for streams of a few thousand viewers in one region.

            Step 1 of 5

            Post a comment

            Store and check before anything fans out: the comment service takes a per-stream sequence number, writes the comment and runs moderation with a hard 150 ms timeout. Only passing comments reach the dispatchers.

            6 interview moments

            You’re the candidate

            The interviewer pushes on the hard parts. Pick an approach and see how it holds up.

            1. Deep dive 1 of 6

              Interviewer

              “Ten million viewers must see new comments within two seconds. How do their phones receive them?”

              Your move. Pick an approach:

            2. Deep dive 2 of 6

              Interviewer

              “750 gateways, 100,000 live streams, most watched by a handful of people. How does a comment reach only the gateways that need it?”

              Your move. Pick an approach:

            3. Deep dive 3 of 6

              Interviewer

              “One stream has 10 million viewers and, at a wicket, 20,000 comments a second. What do you deliver?”

              Your move. Pick an approach:

            4. Deep dive 4 of 6

              Interviewer

              “Two friends watch side by side, and one phone reconnects. How do you keep comments in order, with no repeats or gaps?”

              Your move. Pick an approach:

            5. Deep dive 5 of 6

              Interviewer

              “A comment must be stored, checked and shown to 10 million people within two seconds. In what order?”

              Your move. Pick an approach:

            6. Deep dive 6 of 6

              Interviewer

              “The player shows “9.8M watching”. How do you count viewers while millions connect and drop during a surge?”

              Your move. Pick an approach:

            Build-up · 8 steps

            Follow one comment, end to end

            Comments and reactions go up over HTTP; events come down one persistent connection per viewer. The two paths meet only at the dispatchers.

            Step 1 of 8

            Connect

            The app opens one SSE connection through the edge load balancer to a gateway. The gateway adds it to its in-memory table, registers the stream if it’s new here, and sends the last 50 events from its ring buffer.