An overview of the

  • preface
  • What is service registration, service discovery
  • There are two ways to register services
  • There are two ways to discover services
  • Common third-party registration tools
  • Afterword.

preface

I haven’t updated it for quite a while. Some friends ask me if I have updated it. It seems that people still like reading my article. Mainly this paragraph is busy reviewing some things of the algorithm, also don’t want to write a reproduction. ** If my article is helpful to you, welcome to pay attention to, like, forward, so that I will be more motivated to do original sharing. **OK, get down to business!

What is service registration, service discovery

Here is a more complete service registration and service discovery process:

Two ways to register a service

There are two ways to register a service:

  • Client registration Client registration is: the service registration and service logout logic written into the code, when a microservice is started, the information is written into the registry, when a microservice offline, the corresponding information is cancelled. Moreover, different programming languages are required to implement the same set of logic. There is some intrusion into the business code. During this time, there is a need to maintain a heartbeat between the registry and the microservices.

  • The Registrar is via a separate service to register and deregister the third-party registration. The Registrar will somehow notify the Registrar when the service is launched, and the Registrar will then initiate registration with the Registrar. At the same time, the registry maintains a heartbeat between services and unregisters services when they are unavailable.

Two ways of service discovery

  • The client is responsible for obtaining the corresponding IP address and port from the registry. Multiple languages need to implement the same logic, which is redundant.
  • Server-side discovery is implemented by the API Gateway so that a language can easily maintain service discovery.

Common third-party registration tools

Registrator Registrator automatically registers and deregisters a container by checking its online or offline status. It currently supports ETCD, Consul, ZooKeeper, and SkyDNS 2. Link transfer. It is often used in conjunction with the following tools to automate service registration.

Zookeeper Originated from Hadoop, ZooKeeper is very mature and stable. Many large companies use a high-performance distributed application coordination service for name service, distributed locking, shared resource synchronization, and distributed configuration management.

Etcd EtCD is a key/value pair storage system using the HTTP protocol. It is a distributed and function-level configuration system, which can be used to build a service discovery system. It is easy to deploy, install, and use, and provides reliable data persistence features. It is secure and well-documented. It requires some third-party tools to provide service discovery.

Consul a data store with strong consistency, Consul uses gossip to form a dynamic cluster. It provides tiered key/value storage that not only stores data, but can be used to register devices for tasks ranging from sending notifications of data changes to running health checks and custom commands, depending on their output. On the Consul Web interface, you can view all services and nodes, monitor health check status, and access set key/value pair data by switching data centers.

Afterword.

The next article will be the actual combat, mainly hand by hand to write a small micro service architecture, will learn before practice, not practice is actually difficult to master, please look forward to. Personal knowledge reserve is always limited, if there is a mistake, also ask the big guy to correct. Click to read the original article and link to my Zhihu, where I will correct the mistakes in the article. This article was first published in the public account “zone7”, pay attention to the public account to get the latest tweets, background reply [xiaobai micro service] to get the source code.

Reference: Service discovery: Zookeeper vs ETCD vs Consul Service registration and discovery