Server Mayor — System Design

Plan a server city: 10 levels of load balancers, cache, CDN and database sharding. An intro system design game for interview prep.

What you learn in this game

Welcome, Server Mayor. Your job is to build the right infrastructure for every scenario. Pick only the components that are needed: don't over-engineer (too much) or under-engineer (too little).

A Load Balancer spreads requests across several servers. Common algorithms: Round Robin (take turns), Least Connections (to the idlest one), or IP Hash (a user always lands on the same server).

Caching stores the result of a computation/query so it doesn't have to be redone. Redis = in-memory key-value store, ~1ms latency. Cache hit = take it from Redis. Cache miss = query the DB, then store it in Redis.

A Message Queue separates request handling from background processing. Example: the user checks out → "Order received!" (instantly) → the email, invoice and inventory are processed in the background by a worker.

What the levels ask

  1. Pick the infrastructure components a simple web app needs.
  2. New scenario: the app and the database belong on separate servers. Why?
  3. Traffic just jumped 10x. One server isn't enough. What do you need?
  4. Database queries are slow and repetitive. Add caching.
  5. Product images load slowly for users outside Java. What's the fix?
  6. Database bottleneck: 90% of the queries are reads. How do you speed it up?
  7. Order processing blocks the response, and the user waits 10 seconds. Move it to the background.
  8. A microservices system needs one front door. Which component?
  9. A notification has to reach 4 different consumers. How do you architect that?
  10. Design the full architecture for an e-commerce site with 100K users/day.
  11. Arrange the request flow from the client for a web app with caching and a database.
  12. Put the flow of a frontend request to a microservice via the API Gateway in order.

And more, 16 levels in all.