Skip to content

Part 11 · Build & Scale a Real Service

Parts 0–10 taught you the concepts and the trade-offs. This part makes them real: you’ll build a working service and then scale it deliberately, one decision at a time — and you’ll measure each step so the improvement isn’t a claim, it’s a number.

We build Snip, a URL shortener — the canonical case study. It’s a simple domain (shorten a URL, redirect to it) but it’s read-heavy, which is exactly what makes caching, replicas, and load balancing pay off in ways you can see.

This part doubles as practical Rust + ops: a real axum web service, Postgres, Redis, a background worker, nginx load balancing, and Docker Compose to run it all.

:::note Honesty up front The Rust code is from a companion project that compiles (cargo build). Running the full stack (app + Postgres + Redis + nginx) uses Docker Compose on your machine — every config you need is in rust/scalable-service/. :::

The book’s thread — what does this buy us, and what does it cost? — stops being abstract here. Each chapter adds one thing, then re-runs the load test:

add a cache → reads get faster (cost: staleness)
add replicas → more throughput (cost: you must be stateless)
add a queue → redirects stay fast (cost: eventual click counts)
  1. The MVP — a minimal axum service: routes, state, /health.
  2. Storage with Postgres — persist links with sqlx.
  3. Caching with Redis — cache-aside on the hot redirect path.
  4. Load Testing & Measuring — p50/p95/p99, a baseline to beat.
  5. Scaling Out — statelessness + replicas behind nginx.
  6. Rate Limiting — a Redis-backed limiter shared across replicas.
  7. Async Work with a Queue — a worker drains click events.
  8. Observability — health, metrics, structured logs.
  9. Resilience — timeouts, retries, graceful degradation.
  10. Deploy with Docker Compose — the whole stack, one command.
  11. Where to Go Next — sharding, CDN, multi-region, and beyond.

Start with The MVP →