Numbers to keep in your head
After this: Use 86,400 seconds in a day, the size steps from KB to PB, and the teaching latencies from tutorial 1.
On this page · 6 sections · 3 checks
The school sum in lesson 1 used "86,400 seconds in a day" without saying where it came from. Estimates use a small set of numbers again and again: the length of a day, the size of a megabyte, the time a database takes. Knowing them by heart makes every sum faster, and it lets you notice when an answer has the wrong number of digits.
Seconds in a day
Work it out once, one step at a time:
- A minute has 60 seconds.
- An hour has 60 minutes, so it has 60 × 60 = 3,600 seconds.
- A day has 24 hours, so it has 24 × 3,600 = 86,400 seconds.
When speed matters more than accuracy, round 86,400 up to 100,000. That is a 1 followed by five zeros, written 10⁵. A number written this way is a : 10³ is 1,000, 10⁵ is 100,000, 10⁶ is 1,000,000. Dividing by 100,000 is the same as removing five zeros, which you can do in your head.
The rounding costs a little: 86,400 is 0.864 of 100,000, so an answer worked with 10⁵ comes out about 14% too small. It still has the right number of digits, and that is what an estimate needs. Lesson 3 does the same sum both ways.
A year has 365 days, so it has 365 × 86,400 = 31,536,000 seconds: about 30 million.
Sizes, in steps of a thousand
Computers count data in . One letter of plain English text takes one byte. Larger amounts get names, and each name is 1,000 times the one before:
| Name | Bytes | Power of ten |
|---|---|---|
| 1 KB (kilobyte) | 1,000 | 10³ |
| 1 MB (megabyte) | 1,000,000 | 10⁶ |
| 1 GB (gigabyte) | 1,000,000,000 | 10⁹ |
| 1 TB (terabyte) | 1,000,000,000,000 | 10¹² |
| 1 PB (petabyte) | 1,000,000,000,000,000 | 10¹⁵ |
To change units, count the steps. MB to TB is two steps (MB to GB, then GB to TB), so 1 TB holds 1,000 × 1,000 = 1,000,000 MB. With powers of ten, subtract the small numbers: 10¹² ÷ 10⁶ = 10⁶.
Times: the teaching numbers
The time one action takes, from start to finish, is its . It is counted in milliseconds (ms): 1,000 ms make one second. Here is the table from tutorial 1.
| Action | Time |
|---|---|
| Read a value from memory | 0.0001 ms |
| Read from an SSD (a fast disk) | 0.1 ms |
| Round trip between two machines in one data centre | 0.5 ms |
| Look a value up in a cache | 1 ms |
| One database query | 10 ms |
| Round trip from London to Virginia | 80 ms |
These are teaching numbers: round on purpose, and real values vary by a factor of several. What matters is the order of size. A cache lookup is ten times faster than a query, and one trip across the ocean takes as long as 8 queries (80 ÷ 10).
One more number from tutorial 1: a server there had 8 workers, each spending 20 ms on a request. Each worker finishes 50 requests per second, so the server finishes 8 × 50 = 400 per second. This tutorial uses 400 for every server.
Run it
Java does not run here. When Java is selected, the block shows the Java version for reading; to run it, paste it into a Java tool on your computer.
The underscores in 1_000_000 are only there to help you read the number: both languages ignore them. // in Python divides and keeps a whole number. Python's whole numbers can grow as large as you need.In Java the L after the first number makes it a long, a whole number that can hold up to about 9 × 10¹⁸. A plain int stops at about 2.1 billion, and 10¹² does not fit.
Check yourself
How many seconds are there in one day?
With 1 KB counted as 1,000 bytes, how many MB are there in 1 TB?
With the teaching numbers, how many database queries take as long as one round trip from London to Virginia?
Honesty notes
- Work out the seconds in a day, 24 × 60 × 60 = 86,400, and round it to 100,000 (10⁵) when speed matters more than accuracy.
- Change units in steps of 1,000: KB, MB, GB, TB, PB, so 1 TB holds 1,000,000 MB.
- Compare times with the teaching latency table: a cache lookup 1 ms, a database query 10 ms, a London to Virginia round trip 80 ms.
- Use 400 requests per second for one server, and say that it depends on the work each request does.