Skip to main content

Service Discovery

Pronunciation
SUR-viss dih-SKUV-uh-ree
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/service-discovery

In short

Service discovery is how services in a distributed system find the current addresses of other services, which change as instances start, stop and move.

What is service discovery?

In a microservice system running on containers or autoscaling groups, instances come and go all the time and get new IP addresses. Hard-coding an address such as 10.0.3.17:8080 would break as soon as that instance is replaced. Service discovery maintains an up-to-date list of healthy instances for each service name, such as payments, and lets callers look them up.

At its center is a service registry, such as Consul, etcd, ZooKeeper or Netflix's Eureka. Instances register themselves when they start, or a platform registers them, and health checks remove instances that stop responding. With client-side discovery, the caller asks the registry and picks an instance itself; with server-side discovery, the caller sends the request to a load balancer or router that does the lookup.

Kubernetes builds this in. A Service gives a stable name and virtual IP to a changing set of pods, and the cluster's DNS resolves names such as payments.default.svc.cluster.local, so applications simply call a name. Service meshes go further, handling discovery, load balancing, retries and encryption in sidecar proxies next to each service.

A common misconception is that DNS alone solves discovery. DNS works for names that change rarely, but caching can keep returning dead instances for minutes and it carries no health information. Discovery systems update within seconds and only return instances that pass their health checks.

Key takeaways

  • Service discovery finds the current addresses of other services.
  • A registry such as Consul or etcd tracks healthy instances by name.
  • Client-side discovery picks instances in the caller; server-side uses a router.
  • Kubernetes Services and cluster DNS provide discovery built in.
  • Plain DNS is too slow and has no health checks for fast-changing systems.

Readers ask

Why do microservices need service discovery?

Because instances are created, destroyed and moved constantly, so their addresses change. Discovery lets services call each other by name and always reach a healthy instance.

What is the difference between client-side and server-side discovery?

In client-side discovery, the calling service queries the registry and chooses an instance. In server-side discovery, it sends requests to a load balancer or router, which queries the registry and forwards the request.

How does Kubernetes do service discovery?

Each Kubernetes Service gets a stable DNS name and virtual IP. The cluster keeps track of which healthy pods back it, and traffic sent to the name is spread across them.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings