Back to blog

Everything is slow and nobody knows why: what do you measure?

Thắng Đoàn
Thắng Đoàn

FotoFlow's feed page has crept up to 2.4 seconds and nobody knows why. Every server's CPU is fine, the database is fine, and the team is trading guesses in chat: maybe the cache, maybe the network, maybe last week's deploy. Metrics tell you something is wrong, traces show where, logs explain why. Without all three you are debugging by superstition.

Numbers over time, and the right ones

Each service already emits metrics: request rate, error share, and latency percentiles, the RED method. Dashboards make the picture clear in one glance: photos and the database are fast, the slowness lives on one path.

Two habits matter here. Watch p99, not averages: one user in a hundred waiting 2 seconds disappears in an average. And alert on what users feel, not on raw CPU. Pick a service level objective, like 99% of feed loads under 1 second, and page someone only when you are burning that budget too fast. A CPU alert fires constantly and means nothing; an SLO alert means users are hurting.

One request, one story

Metrics are aggregates. Logs are the story: timestamped events per service. At thousands of requests a second, lines from different requests interleave into noise, so the fix is a request id handed out at the gateway and printed in every log line. Filter by one id and you read one request's story, end to end. Log structured JSON, not free text, so you can filter by request, user, or service.

The trace completes the picture. Every hop of one request becomes a span with the same trace id, and the waterfall shows exactly where time goes. FotoFlow's trace is unambiguous: 2.1 of the 2.4 seconds are spent waiting on the third-party EXIF-scan API. Fix: a 300 millisecond timeout, cache recent scan results, and p99 drops to 310 milliseconds. OpenTelemetry collects spans from every language, and Jaeger or Tempo explores them.

The 3 a.m. version

Errors spike at 03:12 and the pager fires. The dashboard has deploy and config-change markers, and the marker at 03:10 answers the first question of almost every incident: what changed? Mitigate first, roll the change back, restore service, and investigate the root cause after. Not the other way around.

Afterwards the team writes a post-mortem: timeline, impact, root cause, and the action that stops it happening again, here config changes go through the same canary rollout as code. It is blameless on purpose: the question is how the system let a mistake through, not who made it. Each incident is expensive training data.

What this does not solve

Observability tells you what is happening, but it cannot tell you about demand that has not arrived yet. It also decays: log volume costs money, dashboards rot when services change, and alerts need pruning or the pager gets ignored. The discipline is a scheduled review of what you measure, not a one-time setup. Instrument before you need it. The outage is the wrong time to add logging.

Your feed takes 2.4 seconds. Which of the three signals would tell you the cause today, and which are you missing?
Your CPU alert fired 40 times last month and meant nothing twice. What would you page on instead?

The slow part is found. Next in the series: Twelve engineers, one codebase: is it time to split the app?

Sources

OpenTelemetry

Google SRE Book

System Design Primer

Share:

Recommended for you

Enjoyed this article?

Subscribe for new articles. No spam. Unsubscribe anytime.

No pasting. This is the challenge.0/200

Typed live, never pasted.