Operability and simplicity
easy 25 minA maintainable system is easy to run, easy to understand and easy to change.
See it run
See what a system is doing, repair it safely, and keep it small enough to understand.
Operations
Find one slow request
Metrics say that something is wrong, a trace says where, logs say why.
Step 1 of 5
Normal
- p99 latency
- 240 ms
Requests pass through four parts. Each sends metrics, logs and spans to one place.
Step 1: Normal
alert p99(latency, "orders") > 2 s # thattrace GET /orders 2.1 s # where auth 0.02 s orders 0.10 s db 1.90 slog request_id=abc123 "seq scan on orders" # why- Takes
- Minutes
- You need
- A shared request id
- Reading raw logs on each server
- hours
Pass the request id on every call and put it in every log line. It is the thread through all services.
In the real world
The same operability and simplicity doing real jobs. Pick one and step through it.
What happens when liveness asks the database.
Step 1 of 4
A hiccup
The database is slow for ten seconds. Both servers are healthy.
Step 1: A hiccup
Common mistakes
The bugs interviewers watch for, with the fix beside each.
Liveness that tests dependencies
criticalOne slow database makes the platform restart every healthy copy at the same time.
Wrongdef liveness(): db.ping(); cache.ping() return 200Rightdef liveness(): return 200 # this process answersdef readiness(): return 200 if warmed_up else 503Alerting on causes
majorHigh CPU is often harmless, and the list of possible causes never ends. People learn to ignore the pager.
Wrongalert(cpu > 80)Rightalert(error_budget_burn > 14.4, window="1h")dashboard(cpu)Free-text logs, and secrets in them
criticalNobody can search them by field, and a token in a log is a leaked token.
Wrongprint(f"failed for {user} token={token}")Rightlog("error", "payment failed", request_id=rid, user_id=user.id)Adding parts for later
minorEach part must be patched, watched and explained from today, for a need that may never come.
Wrong# we may need events one daykafka.publish(event)Right# trigger: more than one consumer needs thissave(order)
Interview tips
How to explain it
- Maintainable: easy to run, to understand, to change.
- Metrics say that, traces say where, logs say why.
- Release in small steps that you can undo.
Memory trick: SIMPLE
- Structured logs, Instrumentation, Metrics.
- Probes (health checks).
- Less complexity, Easy deploy.
Health check rules
- Liveness fails: restart. Readiness fails: stop traffic.
- Liveness looks only at itself.
- Readiness must not empty the whole pool.
Before you add a part
- Which number needs it?
- Can something we run already do it?
- Who fixes it at night, and how do they see it?