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 recurring question, made measurable
Section titled “The recurring question, made measurable”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)How we’ll scale it
Section titled “How we’ll scale it”- The MVP — a minimal axum service: routes, state,
/health. - Storage with Postgres — persist links with sqlx.
- Caching with Redis — cache-aside on the hot redirect path.
- Load Testing & Measuring — p50/p95/p99, a baseline to beat.
- Scaling Out — statelessness + replicas behind nginx.
- Rate Limiting — a Redis-backed limiter shared across replicas.
- Async Work with a Queue — a worker drains click events.
- Observability — health, metrics, structured logs.
- Resilience — timeouts, retries, graceful degradation.
- Deploy with Docker Compose — the whole stack, one command.
- Where to Go Next — sharding, CDN, multi-region, and beyond.
Start with The MVP →