Foundations / 3 / 3
Napkin math
Before building a courier-tracking service, size it on a napkin: users to requests per second, requests to bytes per day, bytes to disks, bandwidth and servers. Rough numbers, a few minutes, and the expensive mistakes show up before the first line of code.
- 12 min
- Beginner
- 10 steps
- Peak requests
- 2 000 /s
- Database size
- —
- API egress per second
- —
- App servers
- —
- request
- reply
- redelivery
- duplicate
- lost
Numbers are a model scenario, not measurements
The real request
Courier app → Tracking APIRequest
POST /v1/pings HTTP/1.1
Host: api.example.com
Authorization1: hidden
{
"courier_id": 2"c_1207",
"lat": 341.3111,
"lon": 69.2797,
"ts": 41795392843
}
Response
HTTP/1.1 204 No Content
Authorization· hidden — Each courier's token. A secret, so it is hidden here.courier_id— Who sent it. Pings are looked up by courier, so this will be the first column of the index.lat— Latitude, together withlonthe position. Two numbers, 16 bytes.ts— When the phone took the reading, not when the server got it. Phones can be offline and send late.
Course: 42 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes