Latency
The time data takes to go from one point to another.
Example
Data from Montevideo to a server in Virginia takes about 150 ms round trip; to one in São Paulo, about 30 ms.
Test yourself: Latency
TCP and UDP
In an internet call, a bit of voice arrives 2 seconds late. What's best?
Playing a word 2 seconds late ruins the conversation. UDP drops it and continues with what arrives on time.
PACELC theorem
Network working fine. You want each write on all 3 copies before answering. What do you pay?
If the farthest copy is 80 ms away, each write takes at least 80 ms.
PACELC theorem
A payment system, with no partition. What does it choose?
A payment read stale can be charged 2 times. Waiting 100 ms more for the copies to match is cheap compared with issuing refunds.
0/3
â–¶ PlayLessons that use it
TCP and UDP
Safe or fast
Cache
What's asked often, close at hand
Evicting and spreading the cache
The cache fills up
CDN
Content close to every user
PACELC theorem
CAP plus latency
N-tier architecture
An app in floors
Publish-subscribe
1 message, many listeners
Monoliths and microservices
1 block or many pieces
Microservices done right
Microservices without traps
GraphQL and gRPC
Other ways to talk to an API
Real time: long polling, WebSockets and SSE
Letting the server speak first
Rate limiting
A cap on requests
Requirements and estimates
Ask before you draw
Designing a URL shortener
A long link in 7 characters
Designing WhatsApp
2 billion messages a day
Designing Twitter
1 billion tweets a day
Designing Netflix
1 billion videos watched a day
Designing Uber
10 million rides a day
