F version SpringCloud 3- vernacular Eureka service registration and discovery

Quote: service registration and discovery, like renting the same

Foreword

Luoyang rain today, alas, did not think there wrapped in a down jacket, do not wear the cold wearing a hot embarrassment temperature. School work so many years on the outside, the house is not even a spring coat.

After chatting daily, starting today part of the cheese.

What is SpringCloud said yesterday, he mentioned SpringCloud is actually a collection of many technology today to learn first technical Eureka.

Vernacular service registration and discovery services

Eureka in the micro-system services, the main function is to achieve service management, service registration and discovery, then what is registered with the service find it?

In the first article I mentioned before, is the micro-services project in accordance with the business module to be split, as shown above, trade is an independent service, order of service is independent, can also be deployed as needed for the two service orders a. Then Goods Services required when using orders, orders went to call the service.

In the figure above, but there are several issues need to be addressed:

  1. Goods Services want to call order service, how do you know order service orders and service address 1 2? If a temporary increase in orders for service 3, then how to tell Goods Orders service address 3?
  2. If the order service 1 is down, this time of goods and services if you do not know, still choose to call the service has been down orders 1, the service will call fails. In other words: order service 1 is down, how to put this situation to tell all the other real-time services?
    ......

The solution is to solve the above problem: the introduction of service management, governance is service.

First give life a little chestnut:

  • In an era without the Internet, if you want to rent an apartment needs to find an intermediary, the role of the intermediary is a service manager
  • We are renters, looking for houses, this relationship is like a commodity service to find order service
  • So how come listing it? The landlord when needed rent a house, go to an intermediary, will register their availability of information to the agency there. This process is called registration .
  • We want to rent an apartment, if that Bedroom to rent, you first need to find someone you want to register a list of all agency listings can be found Bedroom from the list. This process is called discovery .
    This example can help you understand the roles of the two registration and discovery process, as well as managers.

Through the above example we get the following figure:

Service governance managers we call registry.

Service Registration: Each service at boot time, tell your registry location.

Service Discovery: Goods Orders want to call service center to get to go first registered location information of all the services, then locate the address of the service order, initiate calls.

Heartbeat mechanism: the service started, every 30 seconds a heartbeat to the registry (is to send a message that the registry to be alive), if the registration center for a long time did not receive a heartbeat for a service, it will think that this service already down, it is removed from the service registration list.

What is Eureka

Spring Cloud encapsulates Netlix developed Eureka module to achieve service governance, management services to dependencies between services, service calls can be achieved, load balancing, fault tolerance, achieve service discovery and registration.

Eureka components

In Eureka architecture, divided into Eureka Server and Eureka client.

Eureka Eureka Server registry

Eureka Server as a service registration function of the server, which is a service registry.

Eureka Server service registration services: after each node starts, it will be registered in EurekaServer, so EurekaServer in the service registry will store all information available information service node, service node can visually see in the interface ( monitoring page)

And other micro-services system, use the client to connect to Eureka Eureka Server and maintain a heartbeat connection. Such systems maintenance personnel can monitor each micro system service is functioning properly by Eureka Server.

Eureka Eureka Client Client

EurekaClient is a Java client, to simplify the interaction, the client Eureka Server also includes a built-in polling (round-robin) load load balancing algorithm.

  • After the application starts, it will send a heartbeat to the Eureka Server (default period is 30 seconds). If Eureka Server does not receive a heartbeat nodes in multiple heartbeat period, EurekaServer will put the service node is removed from the service registry (default 90 seconds)

  • Eureka Client caches the information in the registry service. This approach has some advantages can reduce the pressure Eureka Server is first, followed by all of Eureka Server downtime when the caller can still complete the service call

to sum up

Congratulations, you have completed this chapter, and applaud you! If this article help you, please help thumbs up, comment, forwarding, which the author is very important, thank you.

To grasp SpringCloud more usage, please stay tuned to this series of tutorials.

I welcome public concern number: deer teacher's notes Java, Java technology will be a long-term update graphic tutorials and video tutorials, Java learning experience, Java interview experience and practical development experience in Java.

Guess you like

Origin www.cnblogs.com/bingyang-py/p/12577220.html