Vernacular to explain the micro-service registration and discovery load balancing

file

First, the public library examples

I do not want to directly use professional terms to describe the "micro-service registration and discovery," so we look at life in a case of: "public library." With the continuous improvement of living standards, the pursuit of spiritual food more and more friends. I once saw in some of the city public library, its operating logic is: a number of public organizations and individuals to provide a location and then book donations from the people within the organization to the library. The more books to donate, the more a period of time can borrow books. This practice helps to share books, save money, exchange reading experience. Then we look at a few key areas:

  • Book donations: people within the organization donating books to the public library, is not directly put the book on the shelf to get away with it? Of course not, they are first library management system records about the people who book donations, title, book donations of time and other information, and then put the book on the shelves.
  • Library: library books are usually query via a small program library management system, and then pick up the book, entirely conscious. There may be multiple copies of the books (the same kind of books people donate), library of books people will choose the best according to the state.
  • This is one of the very important role that small library management system and its procedures, as we book donations, the library provides support for data and centralized management capabilities.
  • Part-time librarian books periodic maintenance, the damaged books from library shelves Maintenance Management System.

In fact, this "example of public libraries" above is a typical service registration and discovery:

  • Each book is a service, book donation process is the "service registration" process.
  • Library books query process is the "service discovery" process.
  • One of the most important roles: library management system, administrators and applets, is a service registry or registered service platform.
  • Book donations at the same time could be borrower. Micro registration service node service, but may also use the service discovery mechanism to discover other micro-services.
  • Book donations is proactive behavior, not a passive act. This micro-registration service is the same, slightly services must be actively registered with the service registration component at startup. The aim is to reduce the data maintenance cost, you do not need someone to maintain registration data.
  • Under the book shelf is passive, not active, it will not book donations of shelves. Micro service is the same, the problem occurs when the service fails, registered service discovery component should have the ability to service off the assembly line.
  • The librarian can check the books and shelves, this process is called service registration and discovery: Health Check
  • There may be multiple copies of the same book for the same, by the user choose the best which book to borrow. The results obtained for service discovery: the situation with multiple copies of a service by the service the caller decide which merit a copy of the service. This service more professional way to say is: The client load balancing.

Methods opposed to the client load balancing server load balancing is, if the example above, the process of borrowing a book has multiple copies, up to a librarian or a system by which the borrower a copy of them, this is the service end load balancing.

Second, the service registration and discovery

  • Registration service  - service registration process its service positions in the central registry. Usually register their host and port, and sometimes also register authentication credentials, protocols, and version number or environmental information.
  • Service discovery  - a client application queries the central registry to find the location of the service process.
  • Maintaining the central role of the registry is called service registration platform or service registry

2.1. Registration Service

When a micro service starts, must take the initiative to register their service address registered to the service center for use by other micro-service query calls. The figure for the service registry orange, green micro-services node.

file

2.2. The client load balancing

When there are multiple copies of a micro-services, the use of which is determined by the caller to provide a copy of the service.

file

Three, Spring Cloud common service registry

  • Eureka: Spring Cloud's eldest son, was born in general terms, a limited quality when they grow up
  • Nacos: a rising star, had the eyes of Spring Cloud "other people's children", has been included in the scope of adoption (incubation projects).
  • Apache Zookeeper: relationship between the families, a better relationship with hadoop
  • etcd: relationship between the families, a better relationship with kubernetes
  • Consul: relationship between the families, had better relations with docker

If your application has been used to hadoop, kubernetes, docker, in Spring Cloud implementation can consider using its component relationship between the families, to avoid the registration center set up two sets, save resources. But both easy to talk about the use of compatible, it also needs genuine effort. For the moment, I think the relationship with Spring Cloud should best be Nacos.

Look forward to your attention

Guess you like

Origin www.cnblogs.com/zimug/p/12026827.html