On this Page
On this Guide
- Lesson 07: Service Discovery and API Gateways
- Lesson 08: Service Mesh β Traffic Management, Observability, and Security
- Lesson 09: Securing Microservices β Authentication, Authorization, and mTLS
- Lesson 10: Continuous Integration and Deployment for Microservices
- Lesson 11: Observability β Logging, Tracing, and Metrics
- Lesson 12: Handling Failures and Timeouts in Microservices
What Is Service Discovery?
In a microservice system, services often come and go dynamically (due to auto-scaling, deployments, or failures). Soβ¦
how does Service A know how to reach Service B?
Service discovery solves this by allowing services to register themselves and query other services dynamically.
Static vs Dynamic Discovery
πΉ Static Discovery
- IPs or URLs are hardcoded
- Simple, but fragile and not scalable
πΉ Dynamic Discovery
- Services register themselves on startup
- Others query the registry to get healthy instances
Example:
Service A β DNS / registry β find Service B's IPs β connect
Using a Service Registry
A service registry keeps track of live service instances and their metadata (e.g., version, zone, port).
Popular tools:
- πΈ Consul (by HashiCorp)
- πΈ Eureka (by Netflix)
- πΈ Etcd (used by Kubernetes)
- πΈ Zookeeper (legacy systems)
Services register and deregister automatically.
What Is an API Gateway?
An API Gateway sits in front of your services and:
- Routes traffic to the right service
- Enforces authentication and rate limits
- Performs logging, caching, and load balancing
- Can transform requests/responses (e.g., GraphQL β REST)
Itβs your central access point.
Example:
Client β API Gateway β routes to UserService or OrderService
Popular Tools
| Tool | Type | Description |
|---|---|---|
| Kong | API Gateway | Plugin-based, high performance |
| Envoy | Proxy + Discovery | Modern L7 proxy, built-in service discovery |
| NGINX | Reverse Proxy | Can serve as a simple gateway |
| Istio | Service Mesh | Adds policy, security, routing, telemetry |
| Traefik | Gateway + Discovery | Dynamic config with Docker/Kubernetes |
Use gateways to centralize concerns β but avoid turning them into monolith bottlenecks.
Summary
Microservices rely on dynamic service discovery to stay flexible and resilient. API gateways help manage traffic, security, and monitoring across all services. Together, they keep your distributed system connected and reliable.
Next:
Lesson 08 β Service Mesh: Traffic Management, Observability, and Security