Service Discovery Flow
Service discovery is the mechanism by which services in a distributed system locate each other's network addresses dynamically — without hardcoded hostnames — so that deployments, scaling events, and failures don't require configuration changes.
Service discovery is the mechanism by which services in a distributed system locate each other's network addresses dynamically — without hardcoded hostnames — so that deployments, scaling events, and failures don't require configuration changes.
What the diagram shows
This flowchart covers the client-side service discovery pattern, which is the most common approach in Kubernetes and Consul-based environments:
1. Service registers: when a new instance of a service starts, it registers its IP address and port with the Service Registry (e.g., Consul, Eureka, or Kubernetes Service objects). 2. Health check: the registry periodically health-checks registered instances and removes those that fail. 3. Caller queries registry: when Service A needs to call Service B, it queries the registry for healthy instances of Service B. 4. Load balance: the caller (or a sidecar proxy) selects one instance using a load-balancing strategy — round-robin, least connections, or weighted. 5. Call selected instance: the request is sent directly to the selected instance's address. 6. Deregister on shutdown: graceful shutdown triggers deregistration, removing the instance from the pool before connections drain.
Why this matters
Without service discovery, scaling a service requires updating every caller's configuration. With it, new instances self-register and immediately receive traffic — and failed instances are automatically removed from the pool, reducing the need for manual intervention.
Service discovery is a prerequisite for the patterns shown in Microservice Request Chain and API Gateway Request Flow. When an instance becomes unhealthy and calls start failing, the Circuit Breaker Pattern prevents cascading failures while discovery catches up.