Service discovery framework selection: Consul, Zookeeper or etcd?

 

background

This article does not describe the basic principles of service discovery. In addition to the consensus algorithm, and not too many other advanced algorithms, information on the Internet makes it easy for everyone to understand the above is service discovery.
If you are interested to see the conclusions of the students, please skip ahead to the end of the text.
Currently, the market has a lot of service discovery tool, " Open-Source Service Discovery " in an article listed the following open source service discovery tool.

Name Type AP or CP Language Dependencies Integration
Zookeeper General CP Java JVM Client Binding
Doozer General CP Go   Client Binding
Etcd General Mixed (1) Go   Client Binding/HTTP
SmartStack Dedicated Of Ruby haproxy/Zookeeper Sidekick (nerve/synapse)
Eureka Dedicated Of Java JVM Java Client
NSQ (lookupd) Dedicated Of Go   Client Binding
Serf Dedicated Of Go   Local CLI
Spotify (DNS) Dedicated Of N/A Bind DNS Library
SkyDNS Dedicated Mixed (2) Go   HTTP/DNS Library

(1) If using the consistent parameter, inconsistent reads are possible
(2) If using a caching DNS client in front of SkyDNS, reads could be inconsistent


In the above table, the first three are common, major companies are behind the wheels of their own making, not a wide range of applications, I have not studied in depth.
Additionally, this article is written in 14 years, when it did not study Consul, into the table, Consul should be General, CP, Go, No dependency , Http / DNS Library.
As of today, in addition to container frame arrangement k8s, istio / envoy to realize his service discovery mechanism (they are also compatible with third-party service discovery tool), seems to have no other well-known service discovery framework appeared.
Here I zookeeper, etcd, consul compare these three under.

Compare

zookeeper

ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. All of these kinds of services are used in some form or another by distributed applications. Each time they are implemented there is a lot of work that goes into fixing the bugs and race conditions that are inevitable. Because of the difficulty of implementing these kinds of services, applications initially usually skimp on them ,which make them brittle in the presence of change and difficult to manage. Even when done correctly, different implementations of these services lead to management complexity when the applications are deployed.

Introduction of such a zookeeper's official website, translated, zookeeper features are:

  1. As the central server configuration information stored
  2. Naming Service
  3. Distributed Synchronization
  4. Packet Service

We can see, zookeeper not just as it is very large service discovery framework used.
If you just intend to serve as a zookeeper discovery tool, you need to use the function to store its configuration and distributed synchronization. The former can be understood to have consistency kv storage, which provides a unique zookeeper watcher registered in the asynchronous notification mechanisms, real-time status zookeeper asynchronous node can notify the client zookeeper.

Use zookeeper

zookeeper following procedure is used:

  1. Ensure that the selected language sdk, there are some third-party libraries theoretically github, it should be used carefully screened.
  2. Call zookeeper zookeeper server interface.
  3. Registration their service
  4. Listening service acquired by the state watcher
  5. Service providers need to maintain their own heartbeat and zookeeper server.

" Zookeeper C API Guide ," wrote eight articles describes how to use zookeeper c language api.

Generally speaking, zookeeper need fat clients, each client needs through its sdk keep alive the zookeeper service, increases the complexity of writing programs. In addition, it also provides consumers api realize service registration and discovery logic requires service providers to achieve survival test.

etcd

etcd is a key http protocol using distributed storage system, because of its ease of use and simple. Many systems use or support services as part of etcd found, such as kubernetes. But down to business because it is only a storage system, if you want to provide a complete service discovery function must be used with some third-party tools.
For example, with etcd, Registrator, confd combination, will be able to build a very simple and powerful service discovery framework. However, this operation can build a little trouble spots, especially for relatively consul. Most of the scenes are so etcd kv was used for storage, such as kubernetes.

consul

Compared to etcd, zookeeper, consul biggest feature is: It integrates user service discovery popular demand, out of the box, lowering the threshold for use and does not require any third-party tools. The code that implements simple enough.

Consul has multiple components, but as a whole, it is a tool for discovering and configuring services in your infrastructure. It provides several key features:

  1. Service Discovery
  2. Health Checking
  3. KV Store
  4. Multi Datacenter

Started to say, consul features are:

  1. By DNS or HTTP, the application can find them easily rely on the system
  2. It offers a variety of health checks ways: http return code 200, memory is overrun, whether tcp connection is successful
  3. kv storage, and provide http api
  4. Multiple data centers, this point is zookeeper not available.

Use consul

Compared to the zookeeper found that the use of the service, consul does not require specialized sdk integrated into the service, so it does not restrict the use of any language. We look at how the consul general use.

  1. A consul agent must be installed on each server.
  2. consul agent registration services supported by the profile, or register the service via http interface service.
  3. After registration services, consul agent designated by way of health checks, regular inspection service is alive.
  4. If the service you want to search the survival status of other services, only the agent and consul native http request or initiate a request to dns.

Simply put, consul use does not depend on any sdk, relying on simple http request to be able to meet all logical service discovery.
However, every service from the consul agent to obtain the survival status of other services, compared to the zookeeper watcher mechanisms, real-time a little bit weak, need to consider how to improve real-time as possible, the problem will not be great.

to sum up

name advantage Shortcoming interface Consensus algorithm
zookeeper 1. Powerful, not just service discovery
2. Provide watcher mechanism can obtain a service provider real-time status
3.dubbo and other support frame
1. No health checks
2. sdk to be integrated in the service of complex high
3 does not support multiple data center
sdk Paxos
consul 1. Easy to use, does not require integration sdk
2. own health checks
3. Support multiple data centers
4. Provide web management interface
1. Can not get service information in real-time change notification http/dns Raft
etcd 1. Easy to use, does not require integration SDK
2. highly configurable
1. No health checks
2. To complete the service together with third-party tools found
3 does not support multiple data center
http Raft

In order to support multiple data centers in the future, and in order to quickly support different languages ​​such as nodejs, python service, I would choose as our consul service discovery framework, but the issue of access to real-time information service change notifications need to reduce as much as possible.

References:
Consul vs. Other Software
Service Discovery: Zookeeper ETCD VS VS Consul
Consul VS Other software
Comparing ZooKeeper and Consul

 

Guess you like

Origin www.cnblogs.com/sunsky303/p/11127324.html