Service discovery: names, health and front doors
Compare DNS and registries, place endpoint selection, and reason about health checks, stale membership and gateway routing.
18 min7 steps
By the end you can
- Compare DNS discovery with a dynamic service registry
- Distinguish client-side from server-side endpoint selection
- Reason about health-check detection and cached endpoint staleness
- Explain the roles of reverse proxies and API gateways
A stable name hides changing endpoints
DNS
- Query a stable service name
- A/AAAA gives addresses
- SRV adds port, priority, weight
Registry API
- Query registered instances
- Can expose metadata and health
- Requires registry-aware integration
Discovery maps a logical service to candidate endpoints. DNS offers a common naming interface; a registry offers explicit membership and metadata. They can coexist: a registry may expose DNS. Neither interface makes returned endpoints permanently healthy.
The caller can choose an instance
With client-side discovery, the client resolves membership and chooses a destination. Each client library needs selection, refresh and failure handling. Direct calls avoid an extra proxy hop, but client implementations can behave differently.
A proxy can choose for the caller
With server-side discovery, clients call a stable front door; a proxy or load balancer selects the backend. This centralizes routing behavior but creates another capacity and failure boundary. Run the front door redundantly and monitor its discovery freshness.
Health signals arrive late
0 s
Endpoint fails just after a successful check
Just before 10 s
Client caches old DNS answer for 30 s
10 s
One failed check removes endpoint from DNS answers
About 40 s
Client cached answer expires
Here, detection takes up to 10 seconds; a just-refreshed cache retains the endpoint for another 30. About 40 seconds bounds stale discovery only if TTL is honored, one failed check removes the endpoint, publication is immediate, and stale answers are never served. Existing connections have separate lifetimes.
Ready is different from alive
Liveness
- Process can make progress
- Restart policy signal
Readiness
- Can accept new requests
- Membership or routing signal
Draining
- Stop new assignments
- Let in-flight work finish
Remove an instance from new routing before terminating it. Allow discovery propagation and drain in-flight requests. A process can be alive but unable to serve because a dependency is unavailable. Timeouts and bounded retries still matter after a healthy lookup.
Give the front door a clear job
Reverse proxy
- Accept and forward requests
- Can terminate TLS
- Can balance backends
API gateway
- Reverse-proxy capabilities
- API routing and auth policies
- Quotas or request transformation
Discovery
- Supplies candidate endpoints
- Does not itself authorize requests
An API gateway is often a reverse proxy with API policies. These are roles, not necessarily separate boxes. Authenticate and authorize at appropriate trust boundaries; a registry entry is not permission to call a service. Gateway policy and service authorization must agree.
Check your mastery
Mastery
80%
4 of 5 fresh questions
Try a fresh variant, then score at least 80% on the mastery check. Wrong answers link back to the teaching step.
Loading question…
Mastery check
5 questions on fresh variants. One attempt each, no time limit. Score 80% or more to master the lesson.
Answer this step to continue.