SystemDesign.io
Track 1: foundationsID: load-balancer-placement
Mode: structuredDifficulty: beginner⏱️ 15 mins
Module 2 · High-Level Design · 15 min

1 Million Users. 1 Server. Crash.

You can't fit 1,000 people into a tiny restaurant, and you can't send 1,000,000 users to a single server. Let's learn how to distribute traffic using a Load Balancer.

01 / Concept Cards (Theory)

Distributing the Load

Review these concept cards before jumping onto the visual practice canvas.

1. The Supermarket Analogy

Imagine a busy supermarket with 100 customers waiting in line, but there is only 1 cashier. The cashier gets overwhelmed and completely stops working. Now, imagine 4 cashiers and a manager standing at the front. The manager points the next customer to the shortest line. That manager is the Load Balancer.

Without LBAll 10,000 users connect directly to Server A. Server A maxes out its CPU, runs out of memory, and crashes. The website goes offline.
With LB10,000 users connect to the Load Balancer. The LB sends 3,333 to Server A, 3,333 to Server B, and 3,334 to Server C. Nobody crashes.

2. See the Architecture: Single Server vs Multi-Server

Toggle between the two setups below. Watch how data flows through each architecture. In the single server setup, ALL traffic hits one server. In the multi-server setup, the Load Balancer splits traffic evenly.

User🌐 Web Browser📱 Mobile App🌐DNSapi.mysite.comIP addresswww.mysite.comapi.mysite.com🖥️ Web ServerApp + Database + CacheALL on one machine⚠️ Single point of failureFigure 1 — Single Server Setup

3. Interactive Traffic Overload Simulator

Click the "Send Traffic" button rapidly to simulate users visiting your app. See what happens to the server when the Load Balancer is disabled vs enabled.

System running normally.

4. Deep Dive: Layer 4 (L4) vs Layer 7 (L7) Routing

Load balancers operate at different layers of the OSI Model. The choice between L4 and L7 changes performance, cost, and routing capabilities.

Layer 4 — Transport Layer (TCP / UDP)

An L4 Load Balancer works purely with packet headers. It looks ONLY at the Source/Destination IP Address and TCP/UDP Port without opening or decrypting the actual data payload.

⚡ Advantages
  • Ultra-Fast: Millions of requests/sec with minimal CPU.
  • Low Latency: No packet buffer overhead or TLS decryption.
  • Protocol Agnostic: Works for TCP, UDP, gRPC, database connections, MQTT.
⚠️ Limitations
  • No Content Routing: Cannot route based on URL path or HTTP headers.
  • No Cookie Stickiness: Cannot read HTTP cookies for sticky sessions.
  • No TLS Termination: Backend servers must handle SSL certificates.
Real-World Technologies: AWS Network Load Balancer (NLB), HAProxy (TCP mode), IPVS, LVS, F5 BIG-IP.
📦 L4 Packet Inspection Preview
IP: 203.0.113.5PORT: 443[Encrypted Payload: ??? (Opaque)]
➡️ L4 LB routes directly to a backend server based strictly on IP hash or round-robin without reading the request body.
🏢 Where Layer 4 is Used in Industry
1. Real-Time Multiplayer Gaming (e.g., Call of Duty, Valorant): Games stream raw UDP packets containing player positions 60 times/sec. L4 load balancers handle millions of UDP packets per second with <1ms overhead.
2. Database Connections (e.g., PostgreSQL, Redis Shards): DB pools open persistent TCP connections (port 5432 / 6379). L4 LBs route traffic across DB read-replicas without needing to understand SQL syntax.
3. Two-Tier Edge Infrastructure (e.g., Netflix, Uber): Tech giants place an L4 NLB at the outermost internet edge to handle 10,000,000+ raw TCP connections/sec, splitting them across internal L7 proxies.
FeatureLayer 4 (NLB / TCP)Layer 7 (ALB / HTTP)
OSI LayerLayer 4 (Transport)Layer 7 (Application)
Data InspectedIP Address + Port onlyHTTP Path, Headers, Cookies, Query Params
SSL/TLS TerminationPassed through to backendTerminated at Load Balancer
PerformanceUltra-high throughput, ~0.1ms latencyHigh throughput, ~1-5ms latency
Smart Routing❌ None (round-robin / IP hash)✅ Path-based, Host-based, Header-based
Best ForHigh-volume TCP/UDP, gaming, streamingWeb apps, microservices, REST/GraphQL APIs
02 / Practice Exercise

Build Your Architecture

Place a Load Balancer to protect your backend servers from direct traffic.

Interactive CanvasMode: Freeform Drag & Connect

Task: Load Balancer Placement

🎯
Scenario Prompt: You have two Application Servers. A user wants to visit your site. Place a Load Balancer to distribute the traffic, and connect it to your two backend servers.
Available Components (Click to place on canvas):
🖱️Canvas is emptyClick components above to place them onto the canvas.
Drag components to arrange them freely, and click two nodes to connect them.
💡 Drag to move • Click Node A ➔ Node B to connect • Click ✕ to delete
03 / Evaluation Rubric

System Validation Criteria

Our automated rubric checks your design for these critical rules:

Must Have Requirements (Hard Gate):
1. User connects to the Load Balancer first.
2. Load Balancer connects to App Server A.
3. Load Balancer connects to App Server B.
Common Mistakes Checked:
1. User connecting directly to a backend server (bypasses security and scaling).