Skip to content

Service Discovery

  • As microservices grow in number, it becomes important to understand where each service is located and how they can communicate.
  • Asynchronous integration (using message buses or queues) simplifies decoupling; service A sends messages to a shared location that service B consumes from.
  • Synchronous communication increases the need for service discovery (e.g., service A making a direct HTTP or JSON API call to service B).
  • The simplest approach to service discovery is using DNS conventions (e.g., servicename.environment.companyname.com).
  • More advanced setups may use separate DNS names for each microservice, such as orders.companyname.com or devorders.companyname.com.
  • This simple DNS-based approach is recommended for initial setups to avoid unnecessary complexity.
  • As systems grow, more dynamic service registries (like ZooKeeper or Kubernetes services) might be necessary to track where each microservice lives.
  • API gateways are useful for mapping external requests to internal services and centralizing features like authentication, rate limiting, and API keys.
  • API gateways can include developer-facing portals.
  • Typically, API gateways handle requests originating from outside the organization and direct them to the correct internal microservice.
  • Centralized authentication can be handled by a JWT-based layer at the API gateway.
  • Consider starting with DNS-based service discovery as microservices are introduced.
  • Investigate dynamic service registry solutions (e.g., ZooKeeper, Kubernetes) as the system grows.
  • Explore potential benefits of using an API gateway and centralizing authentication and other concerns.