Prompt
What should I use for service discovery in microservices?
Latest observation
For microservices, the best choice for service discovery depends on your platform and how dynamic your environment is.
Common options
1. Kubernetes DNS / Service objects
If you’re running on Kubernetes, this is usually the default answer.
- Services get a stable DNS name like
orders.default.svc.cluster.local - Kubernetes handles IP changes automatically
- Simple, built-in, and widely used
Use this if: your microservices run in Kubernetes.
2. Consul
A strong general-purpose service discovery system.
- Service registry + health checks
- Works across VMs, bare metal, and multiple environments
- Often used with service mesh setups
Use this if: you’re not fully on Kubernetes, or you need discovery across mixed infrastructure.
3. Eureka
Popular in the Spring ecosystem, especially historically.
- Client-side discovery
- Easy to integrate with Spring Cloud
- Less common now outside older Spring-based stacks
Use this if: you already have a Spring Cloud/Eureka setup.
4. Cloud provider-managed discovery
Examples:
-
AWS Cloud Map / Route 53
-
Azure Service Discovery / internal DNS
-
GCP Cloud DNS / service networking
-
Good integration with cloud infrastructure
-
Less operational overhead
Use this if: you’re heavily invested in one cloud provider.
Practical recommendation
If you’re starting fresh:
- Kubernetes? Use Kubernetes service discovery
- Not on Kubernetes? Use Consul
- Spring-only legacy environment? Eureka may still be fine, but Consul is often a better long-term choice
Rule of thumb
For most modern systems:
- Kubernetes + DNS/service names for discovery
- Load balancing + health checks at the platform level
- Avoid building custom discovery unless you have a very specific need
If you tell me your environment (Kubernetes, AWS, VMs, Spring, etc.), I can recommend the best option more specifically.