A System Design in Forty Minutes
Estimating the Load Before You Draw Anything
Last timeWhat Is Actually Being Asked
Where every figure a design quotes comes from, derived out loud to one significant figure from how many people do what how often, with the arithmetic shown.
The scope from the previous stage says store an address under a seven character
code, return it on demand, and count clicks. Nothing in that tells you whether
one machine will do. This is where the figures come from, and the rule is that
each one is derived out loud from two factors, to one significant figure, and
then never revised. Seven minutes.
- the population, the fraction of it active in a day, and how many times each active member acts. Three factors, each guessed separately so each can be argued with separately.
- the seconds in a day, which is 24 times 3600. This is the only constant in the whole estimate worth memorising.
From people to links a day
Two factors, each stated so it can be challenged. Suppose the service is
reachable by about 1,000,000,000 accounts, counting the publishing tools and
automated posters that create most links. Suppose 10 per cent of them create a
link on any given day, and each one that does creates on average one.
So , and , giving
, a hundred million new links a day. That
is the number the rest of the course quotes, and it is worth saying that both
factors are guesses. What makes the estimate defensible is not that the guesses
are right, it is that an interviewer can reject one of them without having to
reject the arithmetic.
Now the conversion. A day is seconds. So
, which is the fact to carry in your head: a million
a day is 11.6 a second. A hundred million a day is a hundred times that, so
writes a second. Round to 1,200.
The behaviour that sets the read rate
A link is created once and followed many times, and how many is a property of
how links are used rather than of the service. One link posted by one person to
a modest audience gets a handful of clicks; one in a newsletter with a million
subscribers gets tens of thousands. Take the mean over all links at 100 clicks
over the life of a link.
So reads a day are , ten billion. Per second,
, round to 120,000 redirects a second.
Notice what just happened to the ratio. Reads a second over writes a second is
, which is the clicks per link figure again. That is
not a coincidence and it is worth keeping: in a steady state the read to write
ratio is exactly the number of reads a record receives over its life, so the
ratio can be estimated directly from behaviour without computing either rate.
The lesson stops here
7 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents