Service Discovery & Service Mesh
In a microservices world, services come and go — scaling up, scaling down, restarting after crashes. How does Service A find Service B? Hardcoded IPs won't work. You need service discovery, and at scale, a service mesh to handle cross-cutting concerns.
The Discovery Problem
In production, a service might have 20 instances across 5 machines. Instances are ephemeral — containers start, die, and reschedule. The caller needs to know: which IP:port is alive right now?
Client-Side vs Server-Side Discovery
| Client-Side | Server-Side | |
|---|---|---|
| Example | Netflix Eureka + Ribbon | Kubernetes DNS + kube-proxy |
| Pros | No extra hop, flexible LB | Language-agnostic, simple client |
| Cons | Client library per language | Extra network hop |
Service Mesh Architecture
A service mesh extracts networking concerns (discovery, load balancing, retries, mTLS, observability) into a sidecar proxy deployed alongside each service instance. The application code knows nothing about it.
Tools Landscape
| Tool | Category | Key Feature |
|---|---|---|
| Kubernetes DNS | Server-side discovery | Built-in, zero config for K8s services |
| Consul | Service registry + mesh | Multi-DC, health checks, KV store |
| Istio | Full service mesh | Traffic shaping, mTLS, canary deploys |
| Linkerd | Lightweight mesh | Simpler than Istio, low resource overhead |
| Envoy | Proxy (data plane) | L7 proxy, used by Istio/Consul/AWS App Mesh |
Real-World Examples
🏢 Lyft — Created Envoy for Service Mesh
- Lyft had 100+ services with inconsistent retry/timeout behavior per language (Python, Go, Java)
- Built Envoy as a universal sidecar proxy — one place for all network policies
- Every service talks to localhost:port; Envoy handles discovery, mTLS, retries, circuit breaking
- Result: consistent networking behavior across all languages, centralized observability
🏢 Kubernetes — Built-in Service Discovery
- Every K8s Service gets a DNS name:
orders.default.svc.cluster.local - kube-proxy maintains iptables/IPVS rules to route to healthy pods
- For most teams, K8s DNS is enough — no extra tooling needed
- Graduate to Istio/Linkerd when you need: mTLS between services, canary routing, per-route retries
Interactive: Service Registry Simulation
Watch services register and deregister. Click buttons to simulate scaling events.