Introduction to Eureka
Article directory
foreword
"Eureka comes from the ancient Greek word, which means "discovered". In the software field, Eureka is a service registration and discovery component open sourced by Netflix Online Video Company, and other Netflix service components (such as load balancer, fuse , gateway, etc.) together, it is integrated as a Spring Cloud Netflix module by the SpringCloud community
1. Introduction to Eureka
Similar to Zookeeper, Eureka is a service registration and discovery component. It was originally mainly used in Amazon's cloud computing service platform AWS. Eureka is divided into Eureka Server and Eureka Client. Eureka Server is the Eureka service registration center, and Eureka Client is Eureka client. end.
Service registration refers to: when each microservice starts, it registers its own network address and other information to Eureka, and the service provider informs the service registration center of its own information such as service name and service ip.
2. Some concepts
-
Register — service registration
当Eureka Client 向Eureka server 注册时,Eureka Client 提供自身的元数据,比如 ip 地址、端口、运行状况指标的URL,主页 地址信息。
-
Renew — service renewal
Eureka Client By default, it will send a heartbeat renewal every 30s, and notify Eureka Server through service renewal that the Eureka Client is still available. Under normal circumstances, if Eureka Server does not receive Eureka within 90 s Client's heartbeat, Eureka Server will delete Eureka Client from the registration list, note: the official website recommends not to change the service renewal interval -
Fetch Registries—Get service registration list information
Eureka Client Gets service registry information from Eureka Server and caches it locally. Eureka Client will use the service registration list information to find other service information, so as to make remote calls. The registration list information is updated regularly (every 30s). The registration list information returned each time may be different from the Eureka Client cache information. Eureka Client will restart Get information for the entire registry. Eureka Server caches all service registry information and compresses it. Eureka Server and Eureka Client can communicate using json and xml data formats. By default, Eureka Client uses JSON to obtain registration list information -
Cancel—Service offline
Eureka Client can send an offline request to Eureka Server when the program is closed. After sending the request, the instance information of the client will be deleted from the service registration list of Eureka Server. The offline request will not be completed automatically, and the following code needs to be called when the program is closed:
DiscoveryManager.getInstance().shudownComponent(); -
Eviction—service removal
By default, when Eureka Client does not send a service renewal (heartbeat) to Eureka Server for 90 consecutive seconds, Eureka Server will delete the service from the service list, that is, service removal
3. Eureka self-protection
When a new Eureka Server appears, it tries to obtain all service instance registration information from adjacent Peer nodes. If there is a failure to obtain information from adjacent Peer nodes, Eureka Server will try other Peer nodes. If Eureka Server can successfully obtain all service instance information. Then set the service renewal threshold according to the configuration information. At any time, if Eureka Server receives service renewals lower than the percentage configured for this value (by default, less than 85% within 15 minutes), the server will turn on the self-protection mode, that is, the information of the registration list will not be removed.
The advantage of this is that if the Eureka Client cannot renew due to Eureka Server's own network problems, the Eureka Client registration list information will not be deleted, that is, the Eureka Client can also be consumed by other services.