Online chess
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 games are live at the evening peak?

      How many moves and messages a second at peak?

        Does every live game fit in one machine?

          How many socket servers hold every player and spectator?

            Build-up · 5 steps

            Build the high-level design

            One functional requirement at a time, ending with a service that plays real games for one region before any hardening.

            Step 1 of 5

            Find an opponent

            A seek joins one pool per time control. Every few seconds a wave pairs the pool by rating, and each game is created on the game server chosen from its game ID. A challenge link skips the pool.

            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

              “Every move, resign, draw offer and flag must apply in one order against one board and two clocks. Where does a live game’s state live?”

              Your move. Pick an approach:

            2. Deep dive 2 of 6

              Interviewer

              “A 1+0 bullet game: White in Chennai is 150 ms from the server, Black in Berlin 30 ms. How do you run the clocks?”

              Your move. Pick an approach:

            3. Deep dive 3 of 6

              Interviewer

              “On a train out of Mumbai, White’s connection drops just after sending a move. How do you resume without applying it twice?”

              Your move. Pick an approach:

            4. Deep dive 4 of 6

              Interviewer

              “At 3 a.m. the 1+0 pool holds a dozen players; on a weekend evening, hundreds. How do you pair them fast and fairly?”

              Your move. Pick an approach:

            5. Deep dive 5 of 6

              Interviewer

              “A world-championship game draws 100,000 live viewers, so each move is 20 MB to deliver. How do you reach them without the players feeling it?”

              Your move. Pick an approach:

            6. Deep dive 6 of 6

              Interviewer

              “Live games sit in memory, and a game server can crash mid-game. When do you write a game to the database?”

              Your move. Pick an approach:

            Build-up · 6 steps

            Follow one game from seek to rating

            Connections at the edge, one owner per game in the middle, results and ratings written once at the end.

            Step 1 of 6

            Seek

            A player taps “3+2”. The socket tier passes the seek to the pairing service, which adds them to the 3+2 pool.