springcloud--Service Governance Mechanism note service governance mechanism
Service Provider
Service Registration
The service provider registers itself on the Eureka Server at boot time by sending a rest request, with some metadata information for its own service.
eureka.client.register-with-eureka=true: Start the registration operation
Service synchronization
Service Renewal
eureka.instance.lease-renewal-interval-in-seconds=30: Call interval for defining service renewal tasks, default 30 seconds
eureka.instance.lease-expiration-duration-in-seconds=90: Used to define the time of service invalidation, default is 90 seconds
Service consumers
Get Service
Service invocation
Services offline
Service Registration Center
Failure culling
Self-protection
eureka.server.enable-self-preservation=false: Turn off the protection mechanism (ensure that the registry can remove the unavailable instances correctly)
SOURCE Analysis
Discoveryclient class
This class is used to help collaborate with Eureka Server.
The Eureka client is responsible for the following tasks:
- Registering a service instance with the Eureka server
- Service Lease to Eureka Server
- Canceling leases to Eureka Server during service shutdown
- Querying the list of service instances in Eureka Server
Eureka client also needs to configure a list of URLs for the Eureka server
Region, Zone
Serviceurls
Service Registration
Service Acquisition and service renewal
Service Registration Center Processing
Detailed configuration
Eureka client configuration is mainly divided into the following two aspects:
- The configuration information related to the service registration, including the address of the service registry, the time interval for service acquisition, the availability zone, and so on.
- The configuration information related to the service instance, including the name of the service instance, IP address, port number, health check path, and so on.
Note: To turn off the "self-protection" feature of the registry by setting the Enableselfpreservation parameter in the class to prevent closed instances from being rejected by the service registry
Service Registration class Configuration
Specify a registration center
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
Or
eureka.client.serviceUrl.defaultZone=http://peer1:1111/eureka/,http://peer2:1112/eureka/
Security check
http://<username>:<password>@localhost:1111/eureka/
Where <username>, <password> the user name, password for the security check information, respectively
Other configurations
Service Instance class configuration
Cross-platform support
- Communication protocols
Slightly...
springcloud--Service Governance Mechanism note