Back to the map

Module 02 · Networking · Lesson 1 of 7

The OSI model, as engineers actually use it

Seven layers on paper, four that matter in practice. Why 'layer 4 versus layer 7' is the question behind load balancers, firewalls and proxies, and how a request descends and ascends the stack.

IntroShould-knowJunior 9 min Updated Nov 2026

Why it matters

Nobody configures the OSI model, but everybody talks in it. A "layer 4 load balancer" forwards TCP connections without reading them; a "layer 7" one reads HTTP and routes by path. A firewall rule, a TLS termination point, a service mesh: each sits at a layer, and knowing which one tells you what it can see and what it cannot. The model is a vocabulary for saying where in the stack a component works.

The idea

The OSI model describes networking as seven layers, each providing a service to the one above and using the one below. In practice the internet runs on the simpler TCP/IP model, and engineers collapse OSI to the four layers that map onto real decisions.

L7 ApplicationHTTP, gRPC, DNS, TLS*Where your code lives. Reverse proxies, API gateways, L7 balancers read this.L4 TransportTCP, UDP, QUICPorts, connections, reliability. L4 balancers, firewalls, NAT work here.L3 NetworkIP, routing, ICMPAddresses and routes between networks. Routers, VPCs, anycast.L2 / L1 Link, PhysicalEthernet, Wi-Fi, fibreLocal delivery and signals. Mostly invisible to application design.*TLS sits between L4 and L7; people call it L5/L6 or just "above TCP".
The layers that matter in practice, with the component types that live at each. Data is wrapped (encapsulated) going down and unwrapped going up.

What each layer gives you

LayerUnitIdentifies byTypical question in a design
L7 ApplicationRequest / messageURL, headers, methodRoute by path or host? Terminate TLS? Cache responses?
L4 TransportSegment / datagramIP + portReliable stream or fast datagrams? Connection limits?
L3 NetworkPacketIP addressWhich network, which region, how routed?
L2 LinkFrameMAC addressRarely in an interview; your cloud handles it

Encapsulation, briefly

When your service sends an HTTP response, the bytes are wrapped in a TCP segment (adding ports and sequence numbers), then in an IP packet (adding addresses), then in a link frame. Each hop along the way reads only the layers it needs: a router looks at IP, a layer 4 balancer at TCP ports, a layer 7 proxy at HTTP. This is why a layer 4 balancer is fast and dumb and a layer 7 proxy is slower and smart.

L4 versus L7: the distinction you will use

A layer 4 device sees connections: source and destination IP and port. It can spread connections across servers and block ports, cheaply and at line rate, but it cannot tell /api/orders from /images/logo.png. A layer 7 device terminates the connection, reads the HTTP request, and can route by path, host or header, rewrite URLs, cache, compress and authenticate. It costs CPU and adds latency, and it must hold TLS certificates if traffic is encrypted.

Trade-offs

Working higher in the stack buys intelligence (routing by content, caching, auth) with cost (CPU, latency, a component that must understand your protocol). Working lower buys speed and protocol-agnosticism with blindness. Most architectures use both: an L4 layer for raw distribution and DDoS protection, an L7 layer for routing and policy.

In an interview

Use the vocabulary precisely and it does work for you: "An L4 network load balancer in front for TCP distribution, then L7 application load balancers that terminate TLS and route by path to services." If asked why not only L7, the answer is cost and the ability to pass non-HTTP traffic through.

Check yourself

You need to send requests for /api/* to one set of servers and /static/* to another. Which kind of load balancer can do this?

The OSI model, as engineers actually use it · Backplane