DEV Community

Cover image for System Design Basics πŸ• + Spring Boot
Abdulfatai Abdulwasiu Aremu
Abdulfatai Abdulwasiu Aremu

Posted on

System Design Basics πŸ• + Spring Boot

I explained System Design to my friend using a pizza shop πŸ•
Turns out it’s the easiest way to get Scalability, Latency, Throughput, Consistency, and Availability!

1️ Scalability – More chefs, more pizzas

@RestController
class PizzaController {
    @GetMapping("/order")
    String orderPizza() { return "πŸ• Pizza ready!"; }
}
Enter fullscreen mode Exit fullscreen mode

1 instance = 10 orders/min
10 instances = 100 orders/min

2️ Latency – How long until your pizza arrives?

@GetMapping("/order")
String orderPizza() throws InterruptedException {
    Thread.sleep(3000); // 3 sec delay
    return "πŸ• Pizza ready after wait!";
}
Enter fullscreen mode Exit fullscreen mode

Delays = unhappy customers

3️ Throughput – Pizzas per minute

Run a load test:

ab -n 1000 -c 50 http://localhost:8080/order
Enter fullscreen mode Exit fullscreen mode

One endpoint, but throughput depends on kitchen β€œpower.”

4️ Consistency – Pizza means pizza

@RestController
class PizzaController {
    @GetMapping("/order")
    String orderPizza() {
        return Math.random() > 0.7 ? "🍝 Pasta?" : "πŸ• Pizza";
    }
}
Enter fullscreen mode Exit fullscreen mode

Users want the same result every time!

5️ Availability – Always open

@GetMapping("/health")
String health() { return "βœ… I’m alive!"; }
Enter fullscreen mode Exit fullscreen mode

Service stays open, even if one instance crashes.

Takeaway

System design is like running a pizza shop πŸ•

  • Scalability β†’ more chefs
  • Latency β†’ wait time
  • Throughput β†’ orders per min
  • Consistency β†’ pizza = pizza
  • Availability β†’ always open

What’s your favorite system design analogy?

Top comments (0)