Skip to content
Hands-on course · 17 days

System design hands-on

You grow a URL shortener into a distributed system and back every decision with a measurement.

  • Free · no subscription
  • 17 days · 75–90 min each
  • 130 drills · with expected output

Companion code on GitHub · PDF and EPUB · edition 2026

Day 1 · Drill 1: The code
# on s1
$ go mod tidy 2>&1 | grep found
$ go vet . && go build -o kurz .
$ ls -l kurz | awk '{print $5, $9}'
$ grep '^require github' go.mod

Expected

go: found github.com/jackc/pgx/v5 in github.com/jackc/pgx/v5 v5.13.0
go: found github.com/jackc/pgx/v5/pgconn in github.com/jackc/pgx/v5 v5.13.0
16035249 kurz
require github.com/jackc/pgx/v5 v5.13.0

What you'll be able to do

  • Generate and read load correctly with k6: open model, p95, Little's Law and the saturation point
  • Scale a service horizontally behind HAProxy, with cache, read replica and queue, and measure every step
  • Protect a system from overload and cascades with idempotency keys, quotas, load shedding, timeouts and a circuit breaker
  • Estimate capacity from your own measurements and write a design document a colleague understands without you

What you need

LabThree VMs with Ubuntu 24.04, SSH access and sudo on a shared network – in the lab 4 vCPU/11 GiB and twice 2 vCPU/3.8 GiB

Day 14A free IP address on the same network as a virtual address for keepalived

InternetInternet access from the VMs for packages, Go modules and downloads from the official release pages

Prior knowledgeThe book is for developers, platform and DevOps engineers and anyone preparing for a system design interview. You should know Linux in the terminal, SSH, systemctl and some SQL. Go helps but is not required.

Set up your labKubernetes locally · Lab VMs

Training plan

One day = one sitting. Every day ends with a checkpoint and a challenge. About 26 hours in total.

Training days

  1. Day 0 The training groundThree empty Ubuntu VMs become the ground on which your URL shortener grows over the next days: database, cache, queue, load balancer and load generator 75 min
  2. Day 1 The app and the first measurementBuild and run the URL shortener kurz and measure it under load for the first time, after first estimating what the result should be 75 min
  3. Day 2 Measuring properlyRaise the load step by step until the system can no longer keep up, predict the bottleneck with Little's Law and prove it, and understand the difference between the open and the closed load model 75 min
  4. Day 3 Scaling horizontally with HAProxyStart a second instance on s2, put HAProxy in front, secure it with health checks, and measure when two instances really handle more than one, and which balancing algorithm matters 75 min
  5. Day 4 Failures at the load balancerDeliberately crash instances, take a machine off the network, restart, and stop the database, counting the errors each time, and configure HAProxy and the app so that users notice nothing 75 min
  6. Day 5 Caching with ValkeyAnswer redirects from Valkey using the cache-aside pattern, measure the hit rate, and find out when a cache makes the system faster and when it only takes load off the database 75 min
  7. Day 6 When the Cache Causes TroubleExperience a cache's cold start under load, coalesce concurrent misses, stop a cascade via health checks, and test what an outage of the cache itself costs 75 min
  8. Day 7 The Database as BottleneckWatch a new feature with a query lacking an index bring the system to its knees, add the index without a write lock, let PostgreSQL run out of connections and pool them with PgBouncer 90 min
  9. Day 8 Read Replicas and Replication LagSet up a read replica on s2, measure the replication lag, let kurz read from the replica, fail on freshly created links and fix the problem 90 min
  10. Day 9 IDs and ShardingMeasure when random codes collide and when a code space is full, distribute the links across two databases, migrate the existing data and see what distribution costs 90 min
  11. Day 10 Asynchronous with NATSCount clicks without slowing down the redirect: first synchronously in PostgreSQL, then via NATS with a dedicated worker, then durably with JetStream. You measure what each variant costs and when clicks get lost or counted twice 90 min
  12. Day 11 Reliable Delivery – Idempotency, Retries, BackoffRepetitions must not do anything twice. You create duplicate links with a perfectly normal client that resends after a timeout, measure what backoff changes and what it does not, build an idempotency key for POST /api/links and make the click counter count every message exactly once 90 min
  13. Day 12 Rate Limiting and BackpressureA single customer must not clog the system for everyone else. You measure where kurz hits its limit when creating links, limit customers per API key in HAProxy, shed overload early instead of piling it up in queues, and slow down an attacker who guesses codes 90 min
  14. Day 13 Timeouts, Circuit Breakers, Cascading FailuresOne hanging component must not drag down the whole system. You make the database vanish without it reporting errors, watch link creation take redirects down with it, and build three layers of protection: timeouts in kurz, a circuit breaker in front of the database, and timeouts with retries at the load balancer 90 min
  15. Day 14 Consistency and CAP by ExampleThe primary fails, and kurz should still be able to write. You put a virtual IP managed by keepalived in front of the database, promote the replica, watch the old primary come back and two databases accept writes at the same time, and clean up the split brain by hand. In the Challenge, consistency costs availability 90 min
  16. Day 15 Capacity Estimation and the Design DocumentYou estimate what kurz needs at 100 million redirects per day, using numbers you measured yourself instead of tables from the web. You check an estimate against reality, find the first bottleneck and write everything into a design document that a colleague understands without you 75 min

More