Easy system-design fundamentals

How do services find each other in a microservices system?

The 30 second answer

Instances come and go, so their addresses can't be hard-coded; a service registry keeps the current list of healthy instances. With client-side discovery the caller asks the registry and picks an instance itself; with server-side discovery the caller hits a load balancer or proxy that does the lookup. In Kubernetes I just use a Service: it gets a stable DNS name and virtual IP, and the platform keeps the list of ready pods behind it.

Could you say this in an interview?

Client-side discovery. The client queries a service registry, which knows the locations of all instances, and load-balances across them itself. microservices.io gives Netflix Eureka (registry) with Ribbon (client) as the classic example, used from Spring Cloud in Spring Boot apps. Fewer network hops, but every client language needs the discovery and balancing logic.

Server-side discovery. The client calls a router or load balancer at a well-known address; the router queries the registry and forwards the request. microservices.io names an AWS Elastic Load Balancer as an example, and notes that Kubernetes runs a proxy on each host that acts as a server-side discovery router. Clients stay simple; the router is one more component to run and scale.

Kubernetes Services and DNS. A Kubernetes Service gives a set of pods one stable name and, for the default ClusterIP type, a virtual IP. The control plane tracks the matching ready pods in EndpointSlices, and kube-proxy (or a replacement) routes the virtual IP to them. Cluster DNS gives each Service a name of the form my-svc.my-namespace.svc. followed by the cluster domain (commonly cluster.local), plus SRV records for named ports, so most applications only need a DNS name.

Registration and health. Instances either register themselves (and send heartbeats) or a platform registers them; either way, the registry must remove dead instances, which is why readiness checks matter.

Common mistakes interviewers listen for.

  • Caching DNS answers forever in the client, so traffic keeps going to old addresses.
  • Treating "registered" as "healthy"; route only to ready instances.
  • Building a custom registry when the platform already provides one.
Sources (4)
  1. microservices.io: Client-side service discoverymicroservices.io
  2. microservices.io: Server-side service discoverymicroservices.io
  3. Kubernetes: Servicekubernetes.io
  4. Kubernetes: DNS for Services and Podskubernetes.io