This article is transferred from: Le byte
This article mainly explains: Java microservice Eureka registry
Service registry is the core component of service management. It is similar to directory service. It is mainly used to store service information, such as provider URL string, routing information, etc. Service registry is one of the most basic facilities in microservice architecture.
Before the popularity of microservice architecture, registries began to appear in distributed architecture systems. For example, Dubbo is a popular distributed framework in China, which is adopted by a large number of small and medium-sized Internet companies. It provides relatively perfect service governance functions, and the implementation of service governance mainly depends on the registry.
What is a registry
The registry can be said to be the “address book” in the micro service architecture, which records the mapping relationship between services and service addresses. In the distributed architecture, services will be registered here. When a service needs to call other services, it will find the address of the service here and call it.
Take a real-life example. For example, there are two usage scenarios of the address book in our mobile phone:
When I want to call Zhang San, I need to find Zhang San by name in the address book, and then I can find his mobile phone number and make a call—— The service found that Li Si had his mobile phone number and told me his mobile phone number. I saved Li Si’s number into the address book. Later, I can find him from the address book—— Service registration address book -? What role (tip: Service Registry)
Summary: the role of the service registry isRegistration of servicesandService discovery。
- Netflix Eureka
- Alibaba Nacos
- HashiCorp Consul
- Apache ZooKeeper
- CoreOS Etcd
- CNCF CoreDNS
Why do I need a registry
After knowing what a registry is, let’s continue to talk about why a registry is needed. In distributed systems, we not only need to find the mapping relationship between services and service addresses in the registry, but also need to consider more and more complex problems:
- How to be found in time after service registration
- How to get offline in time after service downtime
- How to effectively expand services horizontally
- How to route when discovering a service
- How to downgrade when the service is abnormal
- How does the registry achieve its own high availability
The solution of these problems depends on the registry. In short, the function of the registry is a bit similar to DNS server or load balancer. In fact, as the basic component of microservices, the registry may be more complex and require more flexibility and timeliness. Therefore, we also need to learn more spring cloud microservice components to cooperate to complete application development.
What problem has the registry solved
- Service management
- Dependency management of services
What is the Eureka registry
Eureka is a service discovery component developed by Netflix. It is a rest based service. Spring cloud integrates it into its sub project spring cloud Netflix to realize spring cloud service registration and discovery. At the same time, it also provides load balancing, failover and other capabilities.
Eureka registry has three roles
Provide service registration and discovery through register, get, renew and other interfaces.
Application Service（Service Provider）
The service provider registers its own service instance in Eureka server.
Application Client（Service Consumer）
The service caller obtains the service list through Eureka server and consumes the service.
Java micro service Eureka registration center entry case I put in the official account “Yue byte”, the official account needs to send message: 999