Basis Lab

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.

FIG 1Every request rate in a design has this shape
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.
Everything below is this formula with different letters. Writing it out before putting numbers in it is what stops the two commonest errors, which are multiplying a population by a rate it was already expressed in and dividing by the wrong power of ten.

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 P=109P = 10^{9}, f=0.1f = 0.1 and k=1k = 1, giving

109×0.1×1=10810^{9} \times 0.1 \times 1 = 10^{8}, 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 24×3600=86,40024 \times 3600 = 86{,}400 seconds. So

106/86,400=11.5710^{6} / 86{,}400 = 11.57, 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

100×11.57=1,157100 \times 11.57 = 1{,}157 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 108×100=101010^{8} \times 100 = 10^{10}, ten billion. Per second,

1010/86,400=115,74110^{10} / 86{,}400 = 115{,}741, round to 120,000 redirects a second.

Notice what just happened to the ratio. Reads a second over writes a second is

120,000/1,200=100120{,}000 / 1{,}200 = 100, 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 contents

This 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

The rest of this course

  1. 01What a One Line Design Request Actually Asks For
  2. 02Estimating the Load Before You Draw Anythingyou are here
  3. 03The One Machine Version, and the Number at Which It Breaksopening only
  4. 04Where 360,000 Reads a Second Actually Goopening only
  5. 05Splitting the Writes, and the Number That Decides How Many Piecesopening only
  6. 06What a Reader Sees While Something Is Brokenopening only
  7. 07Justifying Every Box in the Drawing With the Number That Forced Itopening only
  8. 08Where Each of the Forty Minutes Goes, and the Two Mistakes That Cost Tenopening only

Read alongside