Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
All topics/Load Balancing & Proxies
FUNDAMENTALS & NETWORKING · SUBTOPIC

Layer 4 vs. Layer 7 Load Balancing

Compare packet-level speed (L4) against HTTP-aware smart routing (L7).

BeginnerPart of Load Balancing & Proxies
Practice in AI HLD
Subtopics in Load Balancing & Proxies (2)
OverviewL4 vs. L7Routing Algorithms

In plain words

An L4 balancer checks only the envelope’s address and forwards it unopened at top speed. An L7 balancer opens the letter, reads what you asked for, and hands it to the specialist department.

Think of it like…

Mailroom sorting by ZIP code (L4) vs. reading the subject line to route to Billing or Support (L7).

Loading interactive diagram
Loading interactive exercise

Theory & how it works

Why real systems often combine both

At massive scale, a fast Layer 4 load balancer (like AWS NLB or Linux IPVS) sits at the front edge and spreads raw TCP connections across a tier of Layer 7 proxies (like Envoy or NGINX), which then inspect HTTP paths and route to backend microservices.

Key points & practical guide

Summary checklist

  • L4 = fast packet forwarding (IP/port)
  • L7 = HTTP-aware routing, TLS termination, header inspection
  • Use L4 + L7 together at high scale

When to use it

  • L4 for raw TCP/WebSocket scale
  • L7 for HTTP path routing, gRPC, and canary traffic splitting

Watch out for

  • Expecting an L4 balancer to route /api vs /static - it cannot see URLs

Quick check

Loading quiz
Parent topic
Load Balancing & Proxies
Next subtopic
Load Balancing Algorithms & Health Checks