LearnastraTHE DESIGN COURSE

Think like a designer / CHAPTER 02

A repeatable interview process

Use a flexible sequence that keeps requirements, architecture, and deep dives connected.

Beginner1h of deliberate study10 questions

Builds on What a system design interview measures.

By the end, you can
  • Apply the seven reference interview steps while adapting the discussion time.
  • Trace read and write paths before optimizing.
  • Choose the next deep dive from a changed requirement, such as offline message history or traffic concentrated in one conversation.

01Use a route through the problem

Lina wants to send Omar “Meet at six.” Omar may be offline, so the service must save the message for a later history read. Use seven questions to build the design:

  1. Clarify requirements. Agree on sending, history and live updates. Define what “sent” means and which features are excluded.
  2. Estimate important load. Calculate the requests or bytes that affect the next decision.
  3. Define the API. Show what Lina sends, what success returns, and how errors and repeats behave. API means application programming interface: the way callers use the service.
  4. Define saved records. Show messages, conversation membership and saved request outcomes, including how requests find them. This is the data model.
  5. Draw the first complete design. Trace a send and a later read through the smallest working set of components.
  6. Investigate the main risk. Show one difficult mechanism or bottleneck and a justified change.
  7. Review failures and costs. Check the original promises after a race, timeout or missing dependency; name the next validation.

For a 45-minute practice, allocate 5 minutes to requirements; 3 each to estimates, API and records; 8 to the first design; 18 to the main risk; and 5 to review. These are practice allocations. If the interviewer asks about ordering early, address it and keep the other unanswered questions visible.

For this example, assume “sent” means safely accepted into history. It does not mean Omar has read it. Group calls are outside the exercise.

02Move from the message to a working design

First calculate the assumed send load:

  1. One million active people ×20 messages/day =20 million sends/day.
  2. Divide 20 million by 86,400 seconds/day ≈231 sends/second on average.
  3. Apply an assumed fivefold peak: about 1,160 sends/second.

This estimates requests, not machine capacity. The service still has to check membership, save each message and deliver updates to recipients.

For the API, Lina supplies the conversation, text and an identifier for this intended send. Call that request r44. In this example the conversation is c9.

The service handles it as follows:

  1. Verify Lina’s identity and current membership in c9.
  2. Begin a database transaction and check whether Lina’s request r44 already has a result.
  3. If it does, compare the submitted intent with the saved one. Return the same result for a matching repeat; reject reuse with different text or conversation.
  4. If it does not, save the message and the r44 result together. The database must enforce uniqueness for Lina’s request identifier, so two simultaneous repeats cannot both insert a message.
  5. Commit those changes together, then return the result. Call the saved message m82, at position 82 in this conversation.
  6. Notify Omar if he is connected. That notification can be retried independently of saving history.

The API returns m82 and its position. The data model stores the message, membership and request-to-result record used by these steps. The transaction makes the message and its retry record complete together or not at all.

Omar later requests messages after position 81. The service checks his membership and returns later saved positions in order. His last applied position is a cursor, a marker saying where to continue.

03Use failure to choose the deep dive

Lose the response after the transaction commits. Lina cannot tell whether the send succeeded. Follow recovery through saved data:

  1. Lina repeats request r44, rather than creating a fresh request identifier.
  2. The service finds the saved mapping from r44 to m82.
  3. It returns m82. It does not append a second message.
  4. Omar can still read position 82 from history even if its notification was lost.

Choose a deeper investigation from the actual risk:

  • If two sends arrive together, explain how the service assigns distinct positions within one conversation.
  • If Omar reconnects after ten minutes, show the history range requested after his saved cursor.
  • If one conversation receives most traffic, identify the machine handling it and measure whether that machine can keep up.
  • If several devices maintain read positions, define which cursor belongs to each device or account.

For each investigation, show the record before the operation, the checked condition, the saved change and the caller’s result. A box labeled queue or database does not explain these decisions.

Finish by checking the agreed behavior:

  • Every send and history read checks membership.
  • A successful send has the required saved history.
  • A repeated send retrieves its original result.
  • A disconnected reader has a history path to recover.

State unresolved work explicitly, such as multi-device cursors, and choose a measurement such as the oldest undelivered message. That identifies what to investigate next.

One chat message through the interview method

One chat message through the interview methodTrace the request through commit before discussing live delivery. Retry r44 resolves to m82 after a lost response. Omar’s cursor restores history even when the notification was missed. Numbered arrows correspond to the connection key below. All connections are directional.Agree the promiseSent means durablyacceptedSend r44Lina belongs to c9Commit m82Store r44 → m82atomicallyLost responseRetry r44Durable historyOmar reads after 81Live notificationMay be missed whileoffline12345One chat message through the interview methodTrace the request through commit before discussing live delivery. Retry r44 resolves to m82 after a lost response. Omar’s cursor restores history even when the notification was missed. Numbered arrows correspond to the connection key below. All connections are directional.Agree the promiseSent means durablyacceptedSend r44Lina belongs to c9Commit m82Store r44 → m82atomicallyLost responseRetry r44Durable historyOmar reads after 81Live notificationMay be missed whileoffline12345One chat message through the interview methodTrace the request through commit before discussing live delivery. Retry r44 resolves to m82 after a lost response. Omar’s cursor restores history even when the notification was missed. Numbered arrows correspond to the connection key below. All connections are directional.Agree the promiseSent means durablyacceptedSend r44Lina belongs to c9Commit m82Store r44 → m82atomicallyLost responseRetry r44Durable historyOmar reads after 81Live notificationMay be missed whileoffline12345

Follow the numbered arrows

  1. Agree the promise → Send r44agree when sending counts as successful
  2. Send r44 → Commit m82authorize and commit
  3. Lost response → Commit m82recover original outcome
  4. Commit m82 → Durable historyretains message 82
  5. Commit m82 → Live notificationannounces accepted message
The send transaction saves r44’s result with message m82. A repeated send retrieves that result. Omar separately recovers missed notifications by reading saved message positions.
Trace the diagram in words
  1. Trace the request through commit before discussing live delivery.
  2. Retry r44 resolves to m82 after a lost response.
  3. Omar’s cursor restores history even when the notification was missed.

DRAW. CALCULATE. EXPLAIN.

Rehearse a chat design in twelve minutes

20 minutes · guided practice

Assume 500,000 active users send 12 messages/day and peak traffic is four times the average. Use 12 minutes to sketch the seven steps, then compare your work.

  1. Calculate average and peak sends.
  2. Specify send and history requests separately from saved records.
  3. Show a lost send response and Omar’s reconnect.
Your self-check
Compare the worked solution
  1. Calculate 500,000 ×12 =6 million sends/day. Divide by 86,400 to get about 69.4/second, then multiply by the assumed 4 to get about 278/second.
  2. Define the send input: conversation, text and one request identifier. The response includes the saved message and position. History reads specify where to continue.
  3. Store membership, messages and a unique sender/request-to-result mapping. In the send transaction, check the mapping; save a new message and its result together only when no matching result already exists.
  4. Lose the success response. The repeated identifier retrieves the original result instead of creating another message.
  5. On reconnect, verify Omar’s membership and read after his last applied position. Live delivery can make him notice a message sooner; saved history provides recovery.

The checkboxes record your own assessment. The worked solution gives you a way to check the reasoning.

RETRIEVE BEFORE YOU REVEAL

Keep the important ideas.

Say the answer aloud, then turn the card over.

CARD 01What is the interview sequence?
  1. Agree on requirements.
  2. Estimate load.
  3. Define the API.
  4. Define stored records.
  5. Trace the first working design.
  6. Explain its hardest risk.
  7. Review failures and costs.

Adapt time to the discussion, and produce an observable result at each step.

CARD 02How do I trace chat correctly?
  1. Save the message and its request-result record together.
  2. Retry or omit live notification without losing saved history.
  3. On reconnect, check membership and read saved positions after the recipient’s last applied cursor.
CARD 03What is a useful deep dive?
  1. Choose a failure that threatens a requirement.
  2. Identify who reads and changes which record.
  3. Explain the condition that permits the change.
  4. Show what survives a crash and how a retry uses that state.
Practise this topic in the revision deck ↗

CHECK THE REASONING

Can you explain the choice?

Answer every question, then finish for an immediate score and an explanation for each answer. Aim for 80%, then revisit any gaps.

1 / 10Lina’s message may be received while Omar is offline. What should be clarified first?
2 / 10Assume 20 million sends/day. What is the average send rate?
3 / 10The server saves send request r44 as message m82, but its response is lost. What should a matching retry return?
4 / 10Omar reconnects after missing notifications. Which path restores history?
5 / 10The interviewer requests ordering details early. What is the best response?
6 / 10Why trace the read after the write?
7 / 10Which distinction keeps interview steps 3 and 4 reviewable?
8 / 10One conversation receives most traffic. Which deep dive follows from that evidence?
9 / 10What should the final review compare?
10 / 10What makes a useful risk deep dive?
0 of 10 answered

CLOSE THE LOOP

Explain it without the page.

Summarise the mechanism, one trade-off, and one failure mode. Then mark this chapter complete.