The Request Path
Question: how does a client’s request reach a healthy instance of the right service, and where along the way are shared policies applied?
Trace one concrete request from the client to the service that answers it. Each hop on the path should have a reason to be there.
Forces
- Latency: distance to the user and the number of hops. Edge caching and geographic routing reduce both.
- Availability: unhealthy instances must leave the pool quickly and new ones must join it.
- Scalability: work is spread across instances, which requires that any instance can serve the request or that routing knows which one can. See horizontal duplication.
- Change: instances come and go, and internal services are split or merged, while the external API stays stable.
- Shared policies: TLS termination, authentication, rate limiting, and logging can live in one place or in every service.
Reaching the system
DNS
The first hop. A client resolves a name to addresses, and resolvers, operating systems, and browsers cache the answer for the record’s time to live (TTL).
DNS balances per resolution, not per request, and does not see an instance’s health. A load balancer still sits behind each address. Anycast is the alternative CDNs use: the same IP address is announced from many locations, and network routing delivers each packet to the nearest one, so no DNS change is needed to move traffic.
In an interview, DNS usually takes one sentence: the client resolves the name and reaches the nearest region. It matters again when failover comes up, because the TTL bounds how fast clients move.
CDN
A content delivery network serves content from distributed locations closer to users. The original notes emphasize reducing delivery distance and reducing the requests that reach origin servers.
Reaching an instance
Load balancer
Distributes incoming traffic across a pool of backend servers. Explain both the routing policy and how the backend pool is discovered and kept current (see service discovery).
Policies to study include random selection, round robin and weighted round robin, least connections, load-aware selection, hashing, and path-based routing. Distinguish L4 and L7 behavior where it matters. NGINX and HAProxy are implementation examples to examine.
Proxy
A forward proxy acts on behalf of clients; a reverse proxy acts on behalf of servers. The notes identify filtering, logging, caching, traffic distribution, and request or response changes as capabilities to consider.
External API
A gateway that combines responses from several services is doing API composition.
Service discovery
A client of an RPC-based service needs the network location of a current, healthy instance.
The original notes describe the naive form as a static configuration file listing server addresses, which is hard to keep current. The more flexible form registers each server with a coordination service such as etcd or ZooKeeper using a time-to-live. When a server stops renewing, the entry expires and the server leaves the pool. Health checks decide which registered instances receive traffic; see health check API.
Between services: sidecar and service mesh
- Sidecar: supporting functionality runs in a separate process alongside the application instance.
- Service mesh: sidecar proxies plus a control plane take over traffic management, discovery, load balancing, telemetry, and failure controls such as retries and circuit breaking. These concerns move out of application code into infrastructure.
A mesh is an alternative to putting the same concerns in a shared library; see microservice chassis. The mesh itself is an instance of the control plane and data plane split. Because the proxies carry every call, a mesh can also inject faults to test those failure controls; see testing the controls.
Leads to
- Every synchronous hop needs timeouts, retries, and circuit breakers.
- The gateway is a natural place to authenticate and pass an access token to services.
- Rate limiting at the edge leads to the rate limiter case.
- Stateless instances behind a load balancer move state elsewhere: data at scale.
Seen in cases
- Ticketmaster: an API gateway routes to the event and booking services and can take on authentication, rate limiting, and logging.
- URL shortener: edge and regional caches in front of a stateless redirect service behind a load balancer.
- Rate limiter: enforcement placed on the request path.
- AI and RAG: the request-and-routing module in the boundary map and layers 0-2 of the RAG runtime. They normalize the request, apply tenant policy and feature flags, and choose an execution path with its budgets.
Gaps
- L4 versus L7 load balancing, and health checking in detail.
- When composition belongs in the gateway, in a BFF, or in a dedicated service.
- DNS internals: the resolution chain from recursive resolver to authoritative server, and record types.
Sources
- API gateway and backends for frontends, client-side discovery, server-side discovery, service registry, self-registration, third-party registration – microservices.io.
- Richardson 2019: chapter 3 (service discovery), chapter 8 (external API patterns).
- Newman 2021: chapter 5 (service discovery, gateways, service meshes), chapter 14 (backends for frontends).
- Kubernetes notes: service discovery on a deployment platform.
- Route 53 routing policies – AWS: latency, geolocation, weighted, and failover records.
Library sources
- Richardson 2019, Microservices Patterns: With Examples in Java – chapters 3 and 8
- Newman 2021, Building Microservices: Designing Fine-Grained Systems, Second Edition – chapters 5 and 14
- Nygard 2018, Release It! Design and Deploy Production-Ready Software, Second Edition – chapter 9, on DNS and load balancing
- Educative 2023: DNS, Grokking Modern System Design Interview
Further reading:
- Xu 2020, System Design Interview: An Insider’s Guide – chapter 1