Course contentsShow
← System Design
Lesson 1536 of 1,91937. Real-World System: URL ShortenerFree lesson

Horizontal Scaling of Redirect Servers

Scale stateless redirect servers horizontally behind load balancers with health checks and auto-scaling policies.

Horizontal Scaling of Redirect Servers

You'll learn how to scale the redirect layer of a URL shortener by adding more stateless servers behind load balancers.

The Core Idea

Once you've deployed your URL shortener to multiple regions (as covered earlier), each region needs to handle massive redirect traffic. The redirect servers that perform URL lookups and HTTP 301/302 redirects are completely stateless—they don't store user sessions or maintain local state. This makes them perfect candidates for horizontal scaling: you can add or remove servers freely without affecting each other.

The architecture works like this: place a load balancer in front of a pool of redirect servers. The load balancer distributes incoming requests across all healthy servers using round-robin, least-connections, or IP-hash algorithms. When traffic spikes (say, a viral link), you add more servers to the pool. When traffic drops, you remove them.

Health Checks and Auto-Scaling

The load balancer continuously performs health checks—periodic pings to each server's /health endpoint. If a server stops responding or returns errors, the load balancer immediately stops routing traffic to it, ensuring high availability.

Auto-scaling policies take this further: based on metrics like CPU usage (>70%), request rate, or response latency, the infrastructure automatically provisions new redirect servers from a template. When load decreases, it terminates excess servers, optimizing cost. This elasticity is crucial for handling unpredictable traffic patterns without over-provisioning.

Think of it like checkout lanes at a grocery store: when lines get long, more cashiers appear; when it's quiet, they close lanes—all coordinated by a manager (load balancer) watching queue length (traffic metrics).

Key Takeaway:
Redirect servers scale horizontally effortlessly because they're stateless—load balancers with health checks and auto-scaling policies dynamically adjust capacity to match traffic demand in real time.