Powers of two, quick scale heuristics, and latency numbers every engineer must know.
What you will learn
Convert between powers of two and powers of ten for storage sizes.
Turn daily and monthly volumes into requests per second.
Use the latency numbers every programmer should know as orders of magnitude.
The power of quick estimation
In system design interviews and architectural planning, you must quickly verify whether a proposed storage format, network pipe, or database tier will survive real-world scale before writing a line of code.
1 day=24×60×60=86,400 seconds≈105 s (easy mental math: divide by 105, then multiply by 1.15).
1 million requests / day≈12 RPS
100 million requests / day≈1,200 RPS
1 billion requests / day≈12,000 RPS
The primer's worked solutions use a handy conversion for monthly volumes: a month has about 2.5 million seconds, so 1request per second is about 2.5 million requests a month, and 400requests per second is about 1 billion a month.
3. Latency numbers every programmer should know
These figures were compiled by Jeff Dean and Peter Norvig and date from around 2012. They are in nanoseconds (ns, billionths of a second), microseconds (µs, millionths) and milliseconds (ms, thousandths). Hardware has moved on since, so use them for orders of magnitude, not exact values. They span more than eight orders of magnitude (from 0.5 ns to 150 ms is a factor of 3×108). If an L1cache reference were scaled up to 1 second:
L1 cache reference (0.5 ns) →1 second
Branch mispredict (5 ns) →10 seconds
L2 cache reference (7 ns) →14 seconds
Mutexlock/unlock (25 ns) →50 seconds
Main memory reference (100 ns) →3.3 minutes
Read 4 KB randomly from SSD (150μswhat its symbols mean) →3.5 days
Read 1 MB sequentially from memory (250μs) →5.8 days
Round trip within the same datacenter (500μs) →11.6 days
Hard disk seek (10 ms) →7.6 months
Send a packet California → Netherlands → California (150 ms) →9.5 years
Follow a request from the client: it crosses the network to the CDN, goes on to an app server that reads data from memory, and the app server reads the rest from a database on disk. Each step costs a different order of magnitude: a main memory reference about 100 ns, a disk seek about 10 ms, and a round trip across an ocean about 150 ms. A quick estimate adds up these steps to see where the time goes.
Client: 1 × Users
CDN: 1 × CDN
App servers: 4 × App server
Database: 1 × Relational database
Client sends requests to CDN
CDN sends requests to App servers
App servers sends requests to Database
Key takeaways
210≈103: KB, MB, GB, TB and PB are each about a thousand times the last.
A day is about 105 seconds, so 1 million requests a day is about 12 a second; a month is about 2.5 million seconds, so 1 request a second is about 2.5 million a month.
A main-memory reference (100 ns) is about 1,500 times faster than a random 4 KB SSD read (150 µs), and a disk seek (10 ms) is slower still; a round trip across an ocean costs about 150 ms.