Skip to content
Theory · Requirements and estimates · lesson 1 of 8

Where to start

What you'll learn

What you'll learn:

  • find out by asking what a system does and for how many people;
  • write functional and non-functional requirements down as numbers;
  • turn users a day into requests a second, and those into a number of servers;
  • estimate data volume and traffic on paper.
An hourglass turns 100M/day into a 120k/s stream: a thick stream of reads splits over five cups, a thin trickle of writes falls into one

The interviewer says: "Design a photo feed: people post photos, and their followers see them in a feed" — and adds nothing more. For 10 thousand users, one service and one database are enough. What if there are 100 million users? Before reading on, extend the diagram for the large version.

Sketch

For 10 thousand users a service and one database were enough. Now there are 100 million: the feed is opened up to 120,000 times a second, and 10 million posts with 3 photos of 200 KB each are published a day. Add what the large version needs, and connect the blocks.

Dinner for four and a wedding

Imagine you are asked to cook dinner. For four people, one stove and one pan are enough. For a wedding of three hundred guests you need several cooks, a cold room and a serving line where plates go out in a stream. The dish is the same, the kitchen is not.

A cook who did not ask how many guests are coming builds the wrong kitchen. A system is the same: a design for 10 thousand users and a design for 100 million are different projects. The analogy breaks in one place: guests can be counted in advance, while the load on a service can only be estimated. So the interviewer expects the order of magnitude, not an exact value.

Three groups of questions

The questions at the start of an interview fall into three groups. Each answers its own question about the system:

  1. What the system does: who uses it and which actions matter most. This gives the functional requirements.
  2. How much: users a day, actions per user, data in one record, years of storage. This gives the load estimates.
  3. How well: how fast to answer, how much downtime is allowed, whether stale data may be shown and whether data may be lost. This gives the non-functional requirements.

The first group says which blocks are needed. The second says how many and how large. The third says where spare copies are needed.

Questions for the photo feed

For the photo feed it is worth asking:

  1. What does a user see in the feed: posts of the people they follow, or a selection made by the service?
  2. How many photos are in one post, and how large are they?
  3. Are comments, likes, people search and notifications needed?
  4. How many people open the app a day, and how many times does each view the feed?
  5. How many posts are published a day, and for how many years are they kept?
  6. How fast must the feed open, and how fresh must it be?
  7. May a published photo be lost?

The interviewer answers:

  • users publish posts with 3 photos of 200 KB each and follow authors;
  • the feed shows posts of followed authors, newest first;
  • 100 million users open the app every day and view the feed 10 times on average;
  • 10 million posts are published a day, and they must be kept for 5 years;
  • the feed opens in under 200 ms, and a new post may reach followers within a few seconds;
  • a published photo must never be lost.

The whole chapter rests on these answers: the requirements, the requests a second and the data volume all come from them.

When the interviewer says "your call"

Sometimes instead of a number you hear "whatever you think is reasonable." It is not a trap: the interviewer checks whether you can make a sensible assumption.

Say it out loud and write it down: "Let's say 100 million users a day, like a large social network". If the interviewer disagrees, they correct you, and only one number has to be recomputed.

Keep assumptions round: 10, 100, 1,000. They are easier to work with in your head, and a more precise estimate would not be more accurate anyway.

How long this takes

The questions take about five minutes of the 45. You do not need every question in the world, only those whose answer changes the design.

A question about the button color does not change the design. A question about how many photos a post holds does: the answer decides where files are stored.

Common mistake

Asking the questions and not writing the answers down. Twenty minutes later the candidate designs a cache and cannot remember how many times a second the feed is opened: 1,000 or 100,000. They ask again or guess, and the interviewer notes that the requirements got lost.

Write the answers on the board right away, in a column, with numbers.

Key points

  • The prompt is short on purpose: what the system does, how many users it has and how well it must work are yours to find out.
  • The questions fall into three groups: what, how much and how well.
  • To "your call" you answer with a round-number assumption said out loud.
  • Write the answers down at once: the whole design rests on these numbers.