AlgoViz

Operability and simplicity

easy 25 min

A 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

0:00 / 4:45

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

  1. 1986

    Fred Brooks, in No Silver Bullet, separates essential complexity, which belongs to the problem, from accidental complexity, which comes from how we build.

  2. 2003

    Ben Treynor Sloss starts the Site Reliability Engineering team at Google: software engineers asked to run production.

  3. 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.

  4. 2010

    Google publishes the Dapper paper on tracing requests through a distributed system. Zipkin and later Jaeger follow the idea.

  5. 2012

    Prometheus is started at SoundCloud. In 2016 it becomes the second project of the Cloud Native Computing Foundation.

  6. 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.

Step 1 of 3

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.

From a heap to a room anyone can run
Where is the red car?

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.

SignalAnswersExampleCosts
LogsWhat happened at one moment?{"level":"error","msg":"DB connection failed"}Grow with traffic; sample or shorten retention
MetricsHow much, how often, is it changing?http_requests_total{status="200"} 42731Cheap, unless labels have too many values
TracesWhere did this request spend its time?API, auth, database, cache, responseUsually sampled
Metrics say that something is wrong, traces say where, logs say why.

One way in, one screen out

An application machine sends its signals to an OpenTelemetry collector, which sends metrics to Prometheus, logs to Loki and traces to Tempo. Grafana reads all three and alerts the person on call.
The application knows one protocol. The stores behind the collector can change without touching it.
JSON
{"ts": "2024-01-15T10:32:07Z", "level": "error", "service": "orders", "msg": "connection failed", "request_id": "abc123", "operation": "create_order", "duration_ms": 1204}
Structured logging: one JSON object per event, always with the same field names. With the request id you can find every line about one request in every service. Never log passwords, tokens or personal data.

Act

Alerts that deserve to wake someone

Four things to measure for any service

  1. 1

    Latency

    How long requests take. Look at the 99th percentile and keep failed requests apart.

  2. 2

    Traffic

    How many requests a second arrive.

  3. 3

    Errors

    The share that fails, including wrong answers with status 200.

  4. 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

budget=(1−0.999)×30 days=43.2 minburn rate=1.44%0.1%=14.4\text{budget} = (1 - 0.999) \times 30\text{ days} = 43.2\text{ min} \qquad \text{burn rate} = \frac{1.44\%}{0.1\%} = 14.4
With a 99.9% target, 1.44% errors burn the budget 14.4 times too fast: 2% of a 30-day budget in one hour. That is the fast-burn page the SRE workbook suggests. A slow burn becomes a ticket.

Page, ticket or nothing?

Escalation: if the first person does not answer within the agreed time, the second is paged.

Health

Health checks that help

CheckQuestionWhen it failsShould look at
StartupHas it finished starting?Keep waiting, then restartIts own initialisation
Liveness, /healthzIs this process stuck?Restart itOnly itself
Readiness, /readyCan it serve right now?Stop traffic to itItself, and parts it cannot work without
Deep, /statusHow are its dependencies?Show peopleDatabase, cache, queue
These are the three Kubernetes probes plus a page for humans.

Who asks, and what they do

The process is fine, so restarting it would not bring the database back.

Release

Deploy without fear

A canary release

Users reach a router in our system. It sends 95 percent of requests to the machine with version 1 and 5 percent to the machine with version 2. Both send metrics to Prometheus, which is compared before the share grows.
Five percent of users meet version 2 first. If its errors or latency are worse, the router goes back to 100% version 1.
WayHowRollbackCost
RollingReplace copies a few at a timeRoll back the same way, minutesLittle extra capacity
Blue-greenRun a full second set, switch all trafficSwitch back, secondsTwice the machines for a while
CanaryGive a small share to the new version, compare, growSet the share to 0%Needs good metrics
Feature flagDeploy it off, turn it on for some usersTurn it off, no deployFlags 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. 1

    Is it a traffic spike?

    Look at requests per second in Grafana.

  2. 2

    Find the hot copies

    kubectl top pods. One hot pod is a different problem from all of them.

  3. 3

    Scale if needed

    Check that the autoscaler is acting and is not at its maximum.

  4. 4

    Look for the cause

    A recent deploy, a loop, a memory leak making the garbage collector work hard.

  5. 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. 1

    Any recent deploy?

    If latency rose with it, roll back first and investigate after.

  2. 2

    External dependencies

    Open a slow trace and see which call takes the time.

  3. 3

    Database

    Review the slow query log and locks.

  4. 4

    Cache

    Check the hit rate. A drop moves the load to the database.

What better operations buy

availability=MTBFMTBF+MTTR720720+4≈99.45%,720720+0.5≈99.93%\text{availability} = \frac{\text{MTBF}}{\text{MTBF} + \text{MTTR}} \qquad \tfrac{720}{720 + 4} \approx 99.45\%,\quad \tfrac{720}{720 + 0.5} \approx 99.93\%
One failure each 720 hours (a month). Cutting the repair from 4 hours to 30 minutes helps as much as failing eight times less often, and is usually cheaper. MTBF here is the time working between failures.

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 AbstractFactoryProviderManager
  • implements IFactoryBuilder and 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

possible connections=n(n−1)2n=4: 6n=20: 190\text{possible connections} = \frac{n (n - 1)}{2} \qquad n = 4:\ 6 \qquad n = 20:\ 190
If any part may talk to any other, five times the parts means about 32 times the connections to understand. Clear boundaries keep most of them from existing.

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.

JobOpen sourceManaged or commercial
MetricsPrometheus (time-series database), Grafana (dashboards)Datadog, New Relic, CloudWatch
LogsElastic Stack (Elasticsearch, Logstash, Kibana), Grafana LokiSplunk, CloudWatch Logs
TracesJaeger (started at Uber, CNCF), Zipkin (started at Twitter), Grafana TempoAWS X-Ray, Datadog APM
CollectingOpenTelemetry Collector, Fluentd, Grafana AlloyVendor agents
PagingPrometheus AlertmanagerPagerDuty, plus a Slack channel
A common open-source set is Prometheus for metrics, Loki for logs, Tempo for traces and Grafana on top. Promtail, the old Loki agent, reached end of life in 2026; Alloy or the OpenTelemetry Collector replaces it.

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. 1

    Can a new developer follow one request in 15 minutes?

    If not, what is missing: names, a diagram, or a smaller design?

  2. 2

    Is there only one way to do each thing?

    Two ways double the questions.

  3. 3

    Could this be simpler?

    Name one part you could delete.

  4. 4

    Are error messages clear?

    They say what failed, for which input, and what to do.

  5. 5

    Is the architecture obvious?

    The folders and services match the words people use.

  6. 6

    Would I understand this in six months?

    Explain why in a comment. The code already says what.

Should we add this part?

Every part costs attention for as long as it exists.

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.

Sources