(Thirty-two) spring cloud micro Services Architecture b2b2c introduction of e-commerce -Consul

Consul Introduction

Please add source e-commerce platform Penguin beg: 1038774626. Consul is HashiCorp company launched the open source tools for implementing service discovery and configuration of distributed systems. Registration and other distributed services and find solutions, Consul of the program more "one-stop" service registration and discovery built into the framework, distribution consistency protocol implementation, health check, Key / Value store, multi-data center solutions, not You need to rely on other tools (such as ZooKeeper etc.). It is relatively simple to use. Consul use the Go language, and therefore has a natural portability (support for Linux, windows and Mac OS X); package contains an executable file only to facilitate the deployment, with Docker and other lightweight containers can seamlessly fit.

Consul advantages:

Raft use algorithms to ensure consistency, more direct than the complex Paxos algorithm. In comparison, zookeeper uses Paxos, and etcd used is the Raft.

It supports multiple data centers, internal and external network services using different ports for monitoring. Multiple data centers single cluster avoid single points of failure in the data center, and is deployed consider network delay, where fragmentation and the like. zookeeper and etcd not support multiple data center capabilities.

Support for health checks. etcd not provide this functionality.

Supports http and dns protocol interface. zookeeper integration is more complex, etcd only supports http protocol.

Official web management interface, etcd no such function.

Comprehensive comparison, Consul registered as a service and configuration management star, more worthy of attention and study.

characteristic:

Service Discovery

health examination

Key / Value store

Multi-data center

Consul role

client: The client, stateless, HTTP and DNS forwarding the request to the server cluster interfaces within the LAN.

server: server, save the configuration information, high availability clustering, in the LAN to communicate with local clients, a wide area network communication with other data centers. The number of each data center server recommended as three or five.

Consul client, the server also supports boast centers, and more to improve its high availability.

Here Insert Picture Description
Consul works:

Here Insert Picture Description

1, when Producer starts, it sends a post request to the Consul, Consul tell their own IP and Port

2, after receiving the registration Consul Producer of every 10s (default) will send a health check request to the Producer, Producer is healthy test

3, when transmitting a GET request Consumer / api / address to the Producer, the Consul will start to get a temporary table storage service IP and Port transmits GET method request and get the IP Port from the table after the Producer / api / address

4, the temporary table will be updated every 10s, contains only passed the health check Producer

Spring Cloud Consul Consul project is for service management implementation. Consul is a highly available distributed system that contains multiple components, but as a whole, to provide service discovery and service configuration tools for our infrastructure in the micro-services architecture.

Consul VS Eureka

Eureka is a service discovery tool. The architecture is mainly client / server, each data center server has a set of Eureka, each typically a usable area. Eureka customers usually use embedded SDK to registration and discovery services. For non-native integration of customers, the official operation of Eureka some of the REST API, other languages ​​can use the API to implement the operation of Eureka Server in order to achieve a non-jvm language Eureka Client.

Eureka provides a view of the weak consistent service, service availability as much as possible. When a client registers with the server, which will attempt to replicate to other servers, but does not provide complete assurance copy. Service registration survival time (TTL) shorter, requiring the client to the server heartbeat detection. Unhealthy or service node stops the heart, causing them out and removed from the registry. Service discovery can be routed to any service registered, due to the heartbeat detection time interval, may cause some service is unavailable. This simplified model allows for easy cluster management and high scalability.

Consul provides some column features, including richer health checks, key-value pair storage, and multiple data centers. Consul needs of each data center has a set of services, as well as each client's agent, similar to using such services like Ribbon. Consul agent allow most applications to become Consul uninformed, registered through the configuration file and perform service discovery through DNS or load balancer sidecars.

Consul provides strong consistency guarantees, because the server using the protocol Raft replication status. Consul supports various health checks, including TCP, HTTP, Nagios / Sensu compatible or script-based TTL Eureka's. Based on the client node to participate in a health check on Gossip Protocol, the distribution of health checks and inspection work, rather than centralized heartbeat that has become scalability challenges. Discovery request is routed to the elected leader, which makes them strong consistency default case. Allows the client to read obsolete taken so that any server process their requests, such as to achieve linear scalability Eureka.

Consul strong consistency means that it can serve as a coordination locked leadership elections and clusters. Eureka does not provide similar assurance, and often requires coordination is required to perform the service or have run ZooKeeper greater consistency requirements.

Consul provides a range of features required to support service-oriented architecture. This includes service discovery, also includes a wealth of health checks, lock, key / values, multiple data centers co-event system and ACL. Consul and consul-template and envconsul tools such ecosystems are trying to minimize the changes required for integration of applications, in order to avoid the need for local integration through the SDK. Eureka is a part of a larger Netflix OSS suite, the suite of applications is expected to relatively uniform and tightly integrated. Therefore Eureka addressed only a small part of the problem, and other tools such as ZooKeeper can be used together.

© Consul strong consistency is brought:

Registration service will be slower compared to Eureka. Consul of the raft because protocol requires a majority of nodes must be written only considered successful when successfully registered Leader hang throughout the Consul during the re-election is not available. Ensure strong consistency at the expense of usability.

Eureka guarantee high availability (A) and eventual consistency:

Registration service is relatively fast, because there is no registration and other information replicate to other nodes, does not guarantee the registration information whether replicate success when data inconsistency, although A, B on the registration information not exactly the same, but each node is still able to Eureka normal external services, which will not find out if the request A query service information, but the request B can be found. Thus ensuring the availability at the expense of consistency.

Other aspects, Eureka is a servlet program, running in a servlet container; Consul is written in go.

Guess you like

Origin blog.csdn.net/wiyzq/article/details/90764162