Service discovery answers a practical question: where should an application send a request for a particular service right now? Instead of configuring an application with the IP addresses of individual payment servers, an engineer gives it a logical name such as payments.internal. A discovery mechanism resolves that name to instance addresses, a proxy listener, or a stable load-balancer endpoint. This separation becomes important when containers, virtual machines, and other workloads are routinely replaced.
A discovery system needs an authoritative representation of available services and their endpoints. Applications can register themselves, or an orchestrator can register and remove instances on their behalf. Registration may include an address, port, protocol, version, zone, and other metadata. DNS-based discovery exposes addresses through records such as A, AAAA, or SRV, while API-based discovery can return richer metadata and support explicit filtering. Clients must support the chosen mechanism; an ordinary hostname lookup does not automatically retrieve an SRV record's port information.
In client-side discovery, the application or its client library obtains endpoints and selects a destination. This avoids a separate forwarding hop but places endpoint selection, refresh behavior, and some failure handling in each client implementation. In server-side discovery, the client contacts a stable intermediary, such as a load balancer or proxy, which selects a backend. This centralizes routing behavior but introduces additional infrastructure, cost, and potentially latency. A sidecar proxy is another arrangement: applications use a local proxy while the proxy receives changing endpoint information from a control plane.
For example, an order service might call inventory.internal while an orchestrator scales the inventory service from three instances to twelve. New instances should become discoverable only when ready to serve requests. During termination, the platform should remove an instance from discovery and allow existing requests to drain before stopping it. Endpoint propagation, DNS caching, and connection reuse mean that removal is not instantaneous. A long-lived connection can continue using an old endpoint even after a DNS record expires.
Health-aware discovery reduces requests to unavailable instances, but registration alone does not prove application readiness. Health information may come from active probes, orchestrator readiness checks, heartbeats, or application-reported status. These mechanisms have different failure-detection delays and blind spots. Engineers should test process crashes, partial network failures, and failed dependencies, and determine whether stale endpoints remain usable when the discovery control plane is unavailable.
Service discovery is a foundation for service meshes, not a synonym for them. A mesh can distribute endpoint information to proxies and add traffic policies, authenticated communication, and request telemetry. Those capabilities are separate: finding a service does not authorize access, encrypt traffic, or generate distributed traces. Proxy metrics and access logs help distinguish resolution failures from connection failures and application errors; useful end-to-end tracing also depends on trace-context propagation.
Operational choices involve consistency, availability, and complexity. Short DNS lifetimes can reduce stale answers but increase lookup traffic, and actual refresh behavior depends on resolver and application caches. API watches can deliver endpoint changes promptly but require reconnect and resynchronization logic. Use bounded timeouts and carefully scoped retries, especially for non-idempotent requests. Across regions or administrative boundaries, define naming, identity, routing, and failover explicitly: a discoverable address is not necessarily reachable, authorized, or appropriate for every caller.