Operability and simplicity
easy 25 minA maintainable system is easy to run, easy to understand and easy to change.
Video lesson · Chapter 1 of 6
Follow a particular customer's wait
Operability in 80 seconds
1:20Reel coming soon
Theory
Read or listen first. About 2 min.
What it is
Maintainability is how easily people can keep a system working and change it. It has three parts. Operability means it is easy to run. Simplicity means it is easy to understand. Evolvability means it is easy to change.
None of the three is a feature a user can click. They decide how long a problem lasts, how scared people are of a release, and how fast a new colleague becomes useful.
Why it exists
A system is written once and then run and changed for years. Most of its cost and most of its trouble come after the first release. If nobody can see what it is doing, every problem starts with guessing.
Complexity makes this worse. Some of it belongs to the problem and cannot be removed. The rest we added ourselves, and it hides bugs, slows every change and makes failures harder to explain. Removing it is work that pays every day.
A short history
1986
Fred Brooks, in No Silver Bullet, separates essential complexity, which belongs to the problem, from accidental complexity, which comes from how we build.
2003
Ben Treynor Sloss starts the Site Reliability Engineering team at Google: software engineers asked to run production.
2009
John Allspaw and Paul Hammond of Flickr give the talk "10+ Deploys per Day". The first DevOpsDays is held in Ghent the same year.
2010
Google publishes the Dapper paper on tracing requests through a distributed system. Zipkin and later Jaeger follow the idea.
2012
Prometheus is started at SoundCloud. In 2016 it becomes the second project of the Cloud Native Computing Foundation.
2019
OpenTracing and OpenCensus merge into OpenTelemetry, one open standard for traces, metrics and logs.
Words to know
- Log
- A record of one event, with its time and details.
- Metric
- A number measured again and again over time.
- Trace
- The path of one request through all services, with the time spent in each.
- Liveness and readiness
- Two questions: should this copy be restarted, and should it get traffic now?
- Runbook
- Written steps for a known situation.
- Toil
- Manual, repetitive work that grows with the system and could be automated.
- Accidental complexity
- Difficulty that comes from our choices, not from the problem.
How it works
Step through the idea, or press Play.
Make it visible. Logs, metrics and traces that answer: is it broken, where, and since when?
Understand it
Start here
The toy room
Imagine a room full of toys in one heap. Nobody finds anything, and nobody knows what is broken. An operable room lets you find a toy, see what is broken and know when to tidy. A simple room has just enough boxes, not a hundred tiny compartments.
Easy to run, easy to understand, easy to change: the three parts of maintainability.
The idea
The maintainability triangle
Operability: easy to run
Visible health, predictable behaviour, easy deploy and rollback, good documentation and runbooks, and repairs that need nobody.
Simplicity: easy to understand
Little accidental complexity, clear and consistent patterns, good abstractions, no clever code. New developers understand it quickly.
Evolvability: easy to change
New needs fit without rewriting. It follows from the other two: you can only change safely what you understand and can observe.
How the three support each other
Why it matters: cost, because most of a system's life comes after its first release; time, because simple systems are debugged faster; and happiness, because people enjoy working on code they understand and sleep better when the pager is quiet.
See
Logs, metrics and traces
A car dashboard tells you speed, fuel and warnings without opening the engine. A system needs the same, from three kinds of signal, often called the three pillars of observability.
| Signal | Answers | Example | Costs |
|---|---|---|---|
| Logs | What happened at one moment? | {"level":"error","msg":"DB connection failed"} | Grow with traffic; sample or shorten retention |
| Metrics | How much, how often, is it changing? | http_requests_total{status="200"} 42731 | Cheap, unless labels have too many values |
| Traces | Where did this request spend its time? | API, auth, database, cache, response | Usually sampled |
One way in, one screen out
{"ts": "2024-01-15T10:32:07Z", "level": "error", "service": "orders", "msg": "connection failed", "request_id": "abc123", "operation": "create_order", "duration_ms": 1204}Act
Alerts that deserve to wake someone
Four things to measure for any service
- 1
Latency
How long requests take. Look at the 99th percentile and keep failed requests apart.
- 2
Traffic
How many requests a second arrive.
- 3
Errors
The share that fails, including wrong answers with status 200.
- 4
Saturation
How full the scarcest resource is: memory, connections, queue length.
Google's SRE book calls these the four golden signals. Alert on what users feel, such as errors and slow answers. Put causes such as high CPU on dashboards, or in a ticket: CPU at 85% with fast answers is a busy machine, not an emergency.
Error budget and burn rate
Page, ticket or nothing?
Health
Health checks that help
| Check | Question | When it fails | Should look at |
|---|---|---|---|
| Startup | Has it finished starting? | Keep waiting, then restart | Its own initialisation |
Liveness, /healthz | Is this process stuck? | Restart it | Only itself |
Readiness, /ready | Can it serve right now? | Stop traffic to it | Itself, and parts it cannot work without |
Deep, /status | How are its dependencies? | Show people | Database, cache, queue |
Who asks, and what they do
Release
Deploy without fear
A canary release
| Way | How | Rollback | Cost |
|---|---|---|---|
| Rolling | Replace copies a few at a time | Roll back the same way, minutes | Little extra capacity |
| Blue-green | Run a full second set, switch all traffic | Switch back, seconds | Twice the machines for a while |
| Canary | Give a small share to the new version, compare, grow | Set the share to 0% | Needs good metrics |
| Feature flag | Deploy it off, turn it on for some users | Turn it off, no deploy | Flags must be removed later |
Config belongs outside the code: versioned, different per environment, with secrets encrypted (Kubernetes ConfigMaps and Secrets, HashiCorp Vault). A config change can break a system as badly as code, so it goes through the same canary. Flags such as new_checkout_flow ON and beta_feature_x OFF are run with LaunchDarkly, Flagsmith or a table of your own. A plain Kubernetes Secret is only base64-encoded, so turn on encryption at rest.
Runbooks
The emergency manual
Alert: high CPU and slow answers
- 1
Is it a traffic spike?
Look at requests per second in Grafana.
- 2
Find the hot copies
kubectl top pods. One hot pod is a different problem from all of them. - 3
Scale if needed
Check that the autoscaler is acting and is not at its maximum.
- 4
Look for the cause
A recent deploy, a loop, a memory leak making the garbage collector work hard.
- 5
Escalate
If it lasts longer than 30 minutes, or sooner if users are affected and you have no next step.
Alert: high latency
- 1
Any recent deploy?
If latency rose with it, roll back first and investigate after.
- 2
External dependencies
Open a slow trace and see which call takes the time.
- 3
Database
Review the slow query log and locks.
- 4
Cache
Check the hit rate. A drop moves the load to the database.
What better operations buy
Simplicity
Essential and accidental complexity
With building blocks you can glue the pieces and cut special shapes, and then nobody can change it. Or you can use the standard blocks, and anyone can help rebuild. Software is the same.
Essential: part of the problem
- Tax and interest rules are complicated
- Keeping many editors in sync is hard
- Encoding video needs a lot of computation
Accidental: added by us
- Abstractions for needs nobody has
- Optimising before measuring
- Frameworks and services the problem does not need
Just right
def load_config(path):return json.loads(Path(path).read_text())- Clear, small, does the job
Over-engineered
class AbstractFactoryProviderManagerimplements IFactoryBuilderand 200 more lines- All to read one configuration file
Four habits
Clear abstractions
Hide details behind a small interface:
user_service.get_user(id)instead of raw SQL everywhere.Consistent patterns
One way to do each thing. All APIs follow the same conventions for errors, paging and names.
Remove dead code
Delete unused features and paths. "What if we need it later?" You are not going to need it, and version control remembers.
Measure before optimising
Simple first. Profile, then speed up the part that is slow.
Simple does not mean fewer lines, and not always fewer services. It means fewer things to hold in your head at once. Microservices for everything trades calls in one process for calls over a network, and multiplies what must be run and watched.
Why parts multiply
Tools
The toolbox
Like a mechanic, use a different tool for each job: Grafana to see everything, Loki to search the logs, Jaeger to follow one request. Pick one per row.
| Job | Open source | Managed or commercial |
|---|---|---|
| Metrics | Prometheus (time-series database), Grafana (dashboards) | Datadog, New Relic, CloudWatch |
| Logs | Elastic Stack (Elasticsearch, Logstash, Kibana), Grafana Loki | Splunk, CloudWatch Logs |
| Traces | Jaeger (started at Uber, CNCF), Zipkin (started at Twitter), Grafana Tempo | AWS X-Ray, Datadog APM |
| Collecting | OpenTelemetry Collector, Fluentd, Grafana Alloy | Vendor agents |
| Paging | Prometheus Alertmanager | PagerDuty, plus a Slack channel |
Practice
Good habits, like a hospital
Hospitals wash hands, check vital signs and write everything down. The software versions: log what happened, check health, measure, and write the steps. The last habit is to automate what you do again and again. The SRE book calls that work toil and aims to keep it under half of an SRE's time.
Simplicity checklist
- 1
Can a new developer follow one request in 15 minutes?
If not, what is missing: names, a diagram, or a smaller design?
- 2
Is there only one way to do each thing?
Two ways double the questions.
- 3
Could this be simpler?
Name one part you could delete.
- 4
Are error messages clear?
They say what failed, for which input, and what to do.
- 5
Is the architecture obvious?
The folders and services match the words people use.
- 6
Would I understand this in six months?
Explain why in a comment. The code already says what.
Should we add this part?
Summary
The whole topic in one minute.
Operable systems show what they are doing with logs, metrics and traces, wake people only when users are hurt, release in small reversible steps, and come with runbooks. Health checks let machines do the first repairs.
Simple systems contain the complexity of the problem and little more. Prefer one way of doing things, few parts, clear names and deleted code. The test of both is the same: can someone who did not build it fix it at night?
- Maintainability = operability + simplicity + evolvability.
- Metrics say that, traces say where, logs say why.
- Page for pain users feel; link a runbook; ticket the rest.
- Liveness restarts and looks only at itself. Readiness moves traffic.
- Release small and reversible. Roll back first, investigate after.
- Keep essential complexity, delete accidental complexity.