Service discovery solutions provide the following common functionalities:
- Allow services to register to the directory.
- Allow consumers to find where those services reside.
- There can be various other optional features such as service health checks.
You would use service discovery when you have many APIs that are inter-communicating. Managing all, possibly changing, endpoints by hand in various services is very tedious.
The most common ways service discovery is done:
- DNS: simple but a bit tedious to update e.g. myservice-environment.company.com. Add a good TTL value and point to a load balancer
- Zookeeper: old but battletested technology. Overly complex for what it is but decent if you have it running already
- Consul: excellent service discovery software with health checks, extra points for supporting DNS
- Eureka: niche but usable
- Custom Solution: e.g. by using AWS resource tags
- start with cloud-provider tagging if everything is in the cloud
- easy to implement and manage, and well secure if you setup strict permissions
- start with DNS if working on multi-cloud or on-premises
- just so you have a single point of truth and one way of finding some service
- switch to Consul when these become too much to manage
- more to manage but comes with great benefits