Skip to the content.

🌐 Layer 4 vs Layer 7 Load Balancing / Networking

These terms come from the OSI model. Layer 4 is Transport, Layer 7 is Application.


1️⃣ Layer 4 (Transport Layer)

Definition:

Layer 4 load balancers operate at the Transport Layer of the OSI model, dealing with TCP/UDP connections.

Key Points:

Example:

Analogy:


2️⃣ Layer 7 (Application Layer)

Definition:

Layer 7 load balancers operate at the Application Layer, inspecting HTTP/HTTPS requests and content to make routing decisions.

Key Points:

Example:

Analogy:


3️⃣ Comparison Table

Feature Layer 4 (Transport) Layer 7 (Application)
OSI Layer 4 (Transport) 7 (Application)
Routing Decision IP, TCP/UDP port URL, headers, cookies, content
Speed Fast, low latency Slower, inspects full request
Flexibility Basic load balancing Advanced, content-based routing
Protocol Support TCP, UDP HTTP, HTTPS, WebSocket
Example Tools IP Hash LB, Nginx (TCP mode) Nginx (HTTP mode), HAProxy HTTP

💡 Key takeaway: