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)(Pattern: Self registration A service instance registers itself with the service registry. See http://microservices.io/patterns/self-registration.html.)
- Client query service and send request with cache mechanism and load balance strategy such as round-robin or random( Pattern: Client-side discovery A service client retrieves the list of available service instances from the service registry and load balances across them. See http://microservices.io/patterns/clientside-discovery.html.)
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
- 3rd party registration pattern: a third party called the registrar, which is typically part of the deployment platform, handles the registration. ( See http://microservices.io/patterns/3rd-party-registration.html.)
- Server-side discovery pattern: Client makes a request to a DNS name, which resolves to a request router that queries the service registry and load balances requests. ( See http://microservices.io/patterns/server-side-discovery.html.)
沒有留言:
張貼留言