Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Part 1
A single POST to /v1/orders looks different at every hop. From the client through the L4 load balancer, it's just encrypted TLS bytes. At nginx, the request becomes readable HTTP. Then the API gateway authenticates it and forwards it to orders-svc with a user id. Same request, three different views.
What L4 sees vs what L7 sees
Read down the L4 column. Source IP and port, destination port 443. That's the connection tuple, and nothing else. Host, path, Authorization, JSON body are all hidden inside encrypted bytes. After nginx terminates TLS, every row is visible. One exception: a balancer can sometimes peek at the SNI hostname in the TLS handshake.
L4 decides per connection
The L4 load balancer chooses a backend once, when the client opens a new TCP connection. It uses a hash of the tuple or least connections, and TCP health checks keep dead nginx instances out. That's why throughput is huge. The gotcha: on one long-lived HTTP/2 or gRPC connection, every request lands on the same backend.
nginx decides per HTTP request
The connection reaches nginx, which terminates TLS, so now it can read the actual HTTP request. POST /v1/orders matches the /v1 path and goes to the API gateway, while /assets requests go to static content. nginx can also cache, compress, retry, and balance upstreams. It handles HTTP plumbing, not who the caller is.
The gateway decides per API consumer
Same request, two outcomes. With a valid JWT, the gateway forwards the POST to orders-svc with the user id attached. With an expired JWT, the gateway answers 401 itself, and orders-svc never sees it. Quotas and versioning live here too, so services can skip auth.
Deeper read, richer decision
What a hop can decide is bounded by what it can read. The layer 4 load balancer sees IP and port, so all it can decide is which backend. nginx reads host and path, so it can route, terminate TLS, and cache. The gateway reads the token or API key, so it can allow or enforce a quota.
When one hop is enough
Not every system needs all three hops. In the Single app, nginx alone terminates TLS and balances across app instances. For the Public API, each extra layer answers a requirement: a gateway for external consumers needing keys, quotas and versions, and an L4 LB for stable IPs, connection scale, or non-HTTP traffic.
The lines blur in practice
Products overlap. nginx can rate-limit and call an auth service, Kong is built on nginx, and cloud L7 balancers route by path. So classify by role and the layer a hop reads, not its name, and don't duplicate auth or quotas across hops.
- nginx can rate-limit and call auth
- Kong gateway is built on nginx
- Cloud L7 balancers route by path
Each hop reads deeper: connections, then HTTP, then API consumers.
Classify each hop by the deepest layer it reads and whose policy it enforces: connection spreading at layer 4, HTTP plumbing in the reverse proxy, consumer policy in the gateway. So add a hop only when a requirement needs deeper visibility than the hops you already have can give you.