DHRUVANG Created with Sketch.
Published on

I Built a Horizontal Scaling Lab on My Laptop. Here's What It Taught Me

Most engineers understand horizontal scaling in theory. Very few have felt it running on their own machine.

I built a minimal lab to make this concept click: a simple Node.js API, Docker Compose, and NGINX as a load balancer.

One command spins up $N$ identical containers behind a single entry point:

docker compose up --scale web=3 --build

If you refresh localhost:8080 a few times, you'll see the hostname changes on every request. That's NGINX round-robining across 3 stateless containers—no cloud magic, just local DNS and a few lines of configuration.


What This Lab Teaches in Under 10 Minutes

  • Why stateless services are non-negotiable for horizontal scaling: The moment a container holds state that others can't access, you've broken horizontal scale.
  • How NGINX resolves a single hostname to multiple container IPs: Leverages Docker's internal DNS resolver to route traffic seamlessly.
  • The difference between Load Balancing algorithms: Understanding Round Robin, Least Connections, and IP Hash load balancing, and exactly when each one matters.
  • Dynamic scaling: How to scale up from 3 to 5 containers on the fly without restarting anything.

The Core Mental Model

Your load balancer is the single entry point. Every service behind it must be replaceable.

Stateless is not a nice-to-have. It's the prerequisite.

The entire setup is just about 50 lines of configuration between docker-compose.yml and nginx.conf. No Kubernetes, no expensive cloud setups—just Docker running on your laptop.

Sometimes, the best way to internalize a distributed systems concept is to shrink it down until you can hold it in your hands.

#SystemDesign #Docker #BackendEngineering #SoftwareArchitecture #DevOps