0% completed
Numbers You Should Know
On This Page
How big data is
How long operations take
How many seconds there are
Estimation is multiplication and division. What makes it fast is having a small set of facts already in your head, so that no step in the calculation requires looking anything up.
There are three groups of them: how big data is, how long operations take, and how many seconds are in a day.
How big data is
Each step up the ladder multiplies by about a thousand.
| Unit | Roughly | Something that size |
|---|---|---|
| Byte | One character of text | The letter A |
| Kilobyte (KB) | A thousand bytes | A page of plain text |
| Megabyte (MB) | A million bytes | A high quality photo |
| Gigabyte (GB) | A billion bytes | A feature length movie |
| Terabyte (TB) | A thousand GB | A laptop hard drive |
| Petabyte (PB) | A thousand TB | The photo library of a large service |
A kilobyte is strictly 1,024 bytes, not 1,000. In an estimate, treat it as 1,000. The 2 percent error it introduces disappears next to an assumption like "about 10 percent of users post each day", and it makes every multiplication something you can do in your head.
The sizes worth memorizing are the ones you will multiply by a user count.
| Object | Assume |
|---|---|
| A short text post, with its metadata | Hundreds of bytes |
| A thumbnail image | Tens of KB |
| A compressed photo | Hundreds of KB |
| A minute of streaming video | Tens of MB |
How long operations take
Absolute latencies drift as hardware improves. The ratios between them do not, and the ratios are what change a design.
| Operation | Roughly | Compared with memory |
|---|---|---|
| Read from memory | 100 nanoseconds | 1x |
| Read from an SSD | 100 microseconds | About 1,000x slower |
| Round trip inside one data center | 500 microseconds | About 5,000x slower |
| Seek on a spinning disk | 10 milliseconds | About 100,000x slower |
| Round trip across the world | 150 milliseconds | About 1,500,000x slower |
Three consequences follow from that table, and they show up in almost every design.
Memory is worth a lot. Serving a request from memory rather than from disk is not a small improvement, it is a change of category. That is the entire argument for caching, in one line.
Distance costs more than hardware. A round trip across the world is slower than a disk seek. No faster machine on the other side of the planet fixes that, which is why content is served from locations near the user rather than from one central place.
Round trips add up. A request that makes 10 sequential calls inside the data center has spent 5 milliseconds before doing any work. This is why designs try to make calls in parallel, or fetch in one call what would otherwise take several.
How many seconds there are
This is the fact that converts a business number into an engineering number.
A day has 86,400 seconds. Round it to 100,000. The result is 15 percent low, which is fine, and it makes the division trivial: drop five zeros.
| Per day | Per second |
|---|---|
| 100,000 | 1 |
| 1 million | 10 |
| 100 million | 1,000 |
| 1 billion | 10,000 |
Traffic is never spread evenly across the day, so the average is not the number to build for. Peak traffic is commonly two to three times the average, and a service with a sharp daily cycle can be higher still. State the multiplier you are using and apply it once, at the end.
💡 If you remember nothing else, remember that a day is about 100,000 seconds and that memory is about a thousand times faster than an SSD. Those two facts carry most estimation questions on their own.
Key takeaway: Each unit of data size is about a thousand times the one below it, and a kilobyte can be treated as 1,000 bytes in an estimate. Memory is around a thousand times faster than an SSD, a local network round trip is thousands of times slower than memory, and a round trip across the world is slower than a disk seek, which is why caching and serving content near the user matter so much. A day is about 100,000 seconds, so a daily count becomes a per-second count by dropping five zeros, and peak traffic is usually two to three times the average.
The next lesson, Estimating QPS, Storage, and Bandwidth, puts these facts into the three calculations you will actually be asked for.
On This Page
How big data is
How long operations take
How many seconds there are