See inside your system
Users say the app is slow sometimes. Your servers handle 5,000 req/s and look fine, but you have no numbers, no logs and no way to follow one request.
Play this levelFree with an account. It runs in your browser: build the design, press Run, and watch what breaks.
The lesson
Observability means you can tell what's happening inside from what the system reports. It rests on three kinds of data.
Metrics are numbers over time, such as requests a second, errors and p99. They're cheap and they drive alerts. Logs are records of single events with detail, for finding out why. Traces follow one request across every service, so you can see where its time went.
Alert on what users feel, such as errors and slow pages, not on every busy CPU. And watch p99, not the average: the average hides the slowest 1% of users completely.
What you have to achieve
5,000 requests a second at the busiest hour, 10% of them writes.
- No broken or illegal connections
- Use Monitoring
- Use Logging
- Use Tracing
- No component is overloaded
What you learn
Now when someone says it's slow, a metric shows when, a trace shows where, and a log shows why. You can't fix what you can't see.
Check yourself
Pages are slow, and a request passes through 6 services. What shows which one is slow?
- A metric of CPU use
- A trace of that request
- The average response time
Show the answer
A trace of that request. A trace records the time spent in every step of one request, so the slow step stands out.
The average response time is 90 ms. Why still watch p99?
- The average hides the slowest 1% of users
- p99 is cheaper to measure
- It doesn't matter
Show the answer
The average hides the slowest 1% of users. A few very slow requests barely move the average. p99 shows what the unluckiest users actually wait.
What should wake someone up at 3 a.m.?
- One server's CPU at 80%
- Users getting errors or slow pages
- A log line with the word warning
Show the answer
Users getting errors or slow pages. Alert on symptoms users feel. A busy CPU might be fine, and noisy alerts teach people to ignore them.