CSE Roadmap

Common tier · about 6 hours · 8 parts

Part 4 of 8 · 2 min read

Deep dive

The middle thirty minutes.

Choosing the deep dive. Pick the part where the numbers or the correctness are hardest. Examples: the fan-out in a feed, the lock in a booking, the ordering in a chat, the hot key in a counter. If unsure, ask: "I think the hardest part here is X. Shall I go deep there?"

Shape of a deep dive.

  1. State the problem with a number.
  2. Give the simple answer, and why it fails.
  3. Give the better answer.
  4. Give the cost of the better answer.
  5. Say how you would check that it works (a test or a metric).

Example. "A counter row updated 5,000 times a second becomes a hot spot (problem). A simple row update with a lock fails because the lock serialises writes (simple). Use 16 sharded counters and add them on read (better). The cost: reads add 16 numbers, and a read is slightly out of date (cost). I would watch the lock wait time and the total error against a nightly exact count (check)."

Follow-ups. Typical ones: "What if the traffic is 10 times higher?", "What if this server fails?", "How would you add feature Z?", "How do you test this?" Answer in three steps: restate, change the design, name the new cost.

Hints. When the interviewer says something like "What about the database?", it is a hint. Do not defend the old design. Say "Good point, let me look at that" and work through it. Taking a hint well scores better than ignoring it.

Mistakes. If you notice an error ("I said 500 a second, but it is 5,000"), correct it at once and say what changes. Calm corrections are a strength.

When you are lost. Say what you know, name the unknown, state an assumption and move on. Then return if time allows.

Common mistake

Drawing a large design in minute 5 and then having no time to go deep. Start with the simple design and let numbers tell you what to add.

Check yourself: 1. What are the five steps of a deep dive? 2. How do you take a hint? 3. What is the right response to your own arithmetic error?