In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to use Eureka in springcloud". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use Eureka in springcloud" can help you solve the problem.
What is Service Discovery and Service Registration
To put it simply, if a microservice wants to call another microservice, it must know the address and port information of the microservice. A registry is used to register the micro-services and related information available online, and the micro-services look up the relevant information of other micro-services from the registry. There are two main service discovery modes: client-side service discovery (client-side discovery) and server-side service discovery (server-side discovery).
Client discovery
Server-side service discovery
When a request is sent to a service, the client sends a request to a router, which router is running at a known address. Router queries service registry (which may be implemented in this router), and then sends the request to an available service instance. As follows:
Functions of service discovery components
Service registry
The service registry is a database that records the network information of currently available service instances and is the core of the service discovery mechanism. The service registry provides query API and management API, uses query API to obtain available service instances, and uses management API to achieve registration and logout.
Service registration
Service registration: when the service starts, register the network address of the service in the service registry
Health examination
The service discovery component periodically detects registered services through some mechanisms, and removes a service from the service registry if it is found to be inaccessible (perhaps after several heartbeats).
Service Discovery component: Eureka
Eureka is the service discovery mode of client discovery type.
Eureka comes from production environment
Spring Cloud supports Eureka very well.
The above figure is from the official architecture diagram of Eureka, which roughly describes the working process of the Eureka cluster.
Eureka has two concepts, Region and Zone, which I don't quite understand, so copy it to take a place.
Area (Region):
AWS cloud services have data centers in different parts of the world, such as North America, South America, Europe and Asia. Correspondingly, according to the geographical location, we call the collection of infrastructure services in a region as a region. Through the AWS area, on the one hand, we can make the AWS cloud service geographically closer to our users, on the other hand, users can choose different areas to store their data to meet the compliance requirements. Us East (North Virginia), US West (Oregon), US West (North California), Europe (Ireland), Asia Pacific (Singapore), Asia Pacific (Tokyo), etc. Each region has its own corresponding code, such as: code correspondence
Availability zone (Zone):
Each area of an AWS generally consists of multiple availability zones (AZ), while an availability zone is generally composed of multiple data centers. AWS introduced availability zone design mainly to improve the high availability of user applications. Because the availability zone and the availability zone are independent in design, that is to say, they will have independent power supply, independent network, and so on, so that if there is a problem in one availability zone, it will not affect the other availability zone. In an area, the connection between the availability zone and the availability zone is through a high-speed network, thus ensuring a very low latency. The relationship between AWS region and availability zone is shown in the following figure: availability zone
Every time a user needs to use EC2-related resources, he needs to first select the target area, such as the U.S. East (Northern Virginia) us-east-1. Then when creating an EC2 instance, the user can select the availability zone where the instance is located, such as us-east-1a or us-east-1b. The coding of the availability zone is to add different English letters in the order after the region.
The use of Eureka in springcloud
Eureka consists of two components: Eureka Server and Eureka Client.
Eureka Server provides service registration services. After each node is started, it will register in Eureka Server, so that the information of all available service nodes will be stored in the service registry in Eureka Server, and the information of service nodes can be seen intuitively in the interface.
Eureka Client is a Java client that simplifies interaction with Eureka Server and also has a built-in load balancer that uses the polling (round-robin) load algorithm.
After the application starts, a heartbeat is sent to the Eureka Server (the default period is 30 seconds). If Eureka Server does not receive a heartbeat from a node within multiple heartbeats, Eureka Server removes the service node from the service registry (default is 90 seconds).
Data synchronization between Eureka Server will be completed by means of replication.
Eureka also provides a client-side caching mechanism, so that even if all Eureka Server are hung up, the client can still use the information in the cache to consume the API of other services.
In summary, Eureka ensures the high availability, flexibility and scalability of the system through heartbeat detection, health check, client cache and other mechanisms.
Sources of data and source
The overall code structure is as follows:
This is the end of the introduction to "how to use Eureka in springcloud". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Call method: xml version= "1.0" encoding= "UTF-8"? >
© 2024 shulou.com SLNews company. All rights reserved.