System Design & Architecture Interview Question 4: L4 vs L7 Path Routing
System Design & Architecture Interview Questions · Test 1 · question 4 of 10
A web application exposes a single public hostname over HTTPS. Requests whose URL path starts with /api/ must go to a fleet of API servers, and requests under /static/ must go to a separate fleet of file servers. Clients must keep using the one hostname and the same URLs.
Which load-balancing approach meets this requirement?
Show answer and explanation
Answer:
The routing decision depends on the HTTP request path, which is Layer 7 (application-layer) data. Over HTTPS the path is encrypted, so the load balancer has to terminate TLS before it can read the path and choose a backend pool. Path-based routing and TLS offload are standard features of a Layer 7 load balancer.
Option A works at the transport layer. A Layer 4 balancer sees IP addresses and ports, not URLs, so /api/ and /static/ requests would land on either fleet at random.
Option B works at the DNS level, before any HTTP request exists. It can only pick an IP address for the hostname, never a path, and cached DNS answers make it slow to react to failures.
Option C is still Layer 4. Source-IP hashing gives connection affinity (the same client goes to the same server), but it knows nothing about the URL path.
Reference: Load balancing options - Azure Architecture Center