Reference
in order for one service to invoke another service using RPI, it needs to know the network location of a service instance. => Service Discovery
Using service discovery
Instance IP may change, then Service client need a way to find instance
OVERVIEW OF SERVICE DISCOVERY
Its key component is a service registry, which is a database of the network locations of an application’s service instances
The service discovery mechanism updates the service registry when service instances start and stop.
When a client invokes a service, the service discovery mechanism queries the service registry to obtain a list of available service instances and routes the request to one of them.
APPLYING THE APPLICATION-LEVEL SERVICE DISCOVERY PATTERNS
Service register when start (Self registration pattern, instance information may contain health check URL)
Client query service and send request with cache mechanism and load balance strategy such as round-robin or random
Good and Bad
Good: Handle the scenarios, including legacy system can support this way
Bad: When using some tool such as supported by JVM or Spring, can't be supported in non-JVM environment
it’s usually better to use a service discovery mechanism that’s provided by the deployment infrastructure because of application later implementation limitation.
APPLYING THE PLATFORM-PROVIDED SERVICE DISCOVERY PATTERNS
Platform such as Docker and Kubernetes have a built-in service registry and service discovery mechanism. Ex. DNS, VIP
Good and bad
Good: No application code needed
Bad: Need deployed to Docker or Kubernates