AlgoViz

Operability and simplicity

easy 25 min

A 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

Our systemUsersAPIAuth serviceOrders servicePostgreSQLGrafana
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

Our systemUsersPlatformasks: alive?Load balancerasks: ready?Server 1readyServer 2readyDatabaseslow for 10 s

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

    critical

    One slow database makes the platform restart every healthy copy at the same time.

    Wrong
    def liveness():    db.ping(); cache.ping()    return 200
    Right
    def liveness():    return 200              # this process answersdef readiness():    return 200 if warmed_up else 503
  • Alerting on causes

    major

    High CPU is often harmless, and the list of possible causes never ends. People learn to ignore the pager.

    Wrong
    alert(cpu > 80)
    Right
    alert(error_budget_burn > 14.4, window="1h")dashboard(cpu)
  • Free-text logs, and secrets in them

    critical

    Nobody can search them by field, and a token in a log is a leaked token.

    Wrong
    print(f"failed for {user} token={token}")
    Right
    log("error", "payment failed",    request_id=rid, user_id=user.id)
  • Adding parts for later

    minor

    Each 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?