# Service Communication and Discovery

> Choose synchronous or asynchronous communication between services, and learn how service discovery, service meshes and contracts keep a fleet connected. Free...

Canonical: https://www.internhack.in/roadmaps/tracks/system-design/service-communication
Last updated: 2026-11-28

Choose synchronous or asynchronous communication between services, and learn how service discovery, service meshes and contracts keep a fleet connected.

Intermediate · about 3 hours · difficulty 3/5

Learn first: [Monolith, Modular Monolith and Microservices](https://www.internhack.in/roadmaps/tracks/system-design/monolith-vs-microservices)

Once you have several services, how they talk matters as much as what they do.

### Sync vs async

- **Synchronous** (REST, gRPC): caller waits for a response. Simple and immediate, but couples availability: if inventory is down, checkout is down. Long synchronous chains multiply latency and failure probability.
- **Asynchronous** (events, queues): caller publishes and moves on. Decoupled and resilient, but eventually consistent and harder to trace.

Rule of thumb: use sync calls when the user needs the answer now (is the coupon valid?), async for everything that can follow later (send invoice, update search index).

### Service discovery

Instances come and go, so hardcoded IPs fail.

- **Client-side discovery**: the client asks a registry (Consul, Eureka) and picks an instance.
- **Server-side discovery**: the client calls a stable name; a load balancer or platform routes it. In **Kubernetes**, a Service gives a stable DNS name over changing pods.

### Service mesh

A **sidecar proxy** (Envoy) next to each service handles mTLS, retries, timeouts, traffic splitting and telemetry, configured centrally (Istio, Linkerd). Useful with many services and teams; heavy for small setups.

### Contracts and compatibility

- Version APIs and event schemas; prefer additive changes.
- Use a **schema registry** for events (Avro or Protobuf with compatibility rules).
- **Consumer-driven contract tests** catch breaking changes before deploy.

### Pitfalls

- Deep synchronous call chains (A calls B calls C calls D) for one user request.
- Chatty APIs that need 30 calls to render one screen.
- Adopting a service mesh before you have the basics of timeouts and observability.

You are ready to move on when you can mark each call in a checkout flow as sync or async with a reason and explain how a Kubernetes Service finds healthy pods.

## Key concepts

- **Sync vs async communication**
- **Client vs server-side discovery**
- **Kubernetes Services and DNS**
- **Service mesh and sidecars**
- **Schema registry**
- **Contract testing**

## Mini project

Deploy three small services on a local Kubernetes cluster (kind or minikube) that find each other through Service DNS names. Make one call sync and one async through a queue, then scale and kill pods while watching that calls keep working.

## Check yourself

Why does a chain of five synchronous services, each 99.9 percent available, give lower availability than any one of them alone?

## Free resources

- [Kubernetes Service](https://kubernetes.io/docs/concepts/services-networking/service/) (Kubernetes)
- [Service discovery patterns](https://microservices.io/patterns/server-side-discovery.html) (microservices.io)
- [Istio documentation](https://istio.io/latest/docs/) (Istio)

Previous: [Monolith, Modular Monolith and Microservices](https://www.internhack.in/roadmaps/tracks/system-design/monolith-vs-microservices) · Next: [Reliability Patterns](https://www.internhack.in/roadmaps/tracks/system-design/reliability-patterns)

## More in Architecture Styles and Service Communication

- [Monolith, Modular Monolith and Microservices](https://www.internhack.in/roadmaps/tracks/system-design/monolith-vs-microservices)
- [Service Communication and Discovery](https://www.internhack.in/roadmaps/tracks/system-design/service-communication)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [System Design Roadmap](https://www.internhack.in/roadmaps/tracks/system-design)
