preface

Microservitization is currently a major trend, registry is the most basic component of microservices, is the task arranged in the group before, so share the results, this paper on the current industry more popular microservice components for research, and make a summary.

The body of the

Currently, the research dimensions of microservice components are as follows: community ecological heat, ease of use, performance, DISTRIBUTED characteristics of CAP, current component maintenance status, key functions, etc.

Component is introduced

  1. Eureka: Netflix product, SpringCloud1. X integration, later release announced no longer open source;
  2. Nacos: Alibaba product, SpringCloud-Alibaba integration, recently open source, version 0.9.0, based on SpringBoot2.x, service registry and configuration center can integrate configuration.
  3. Consul: An open source tool from HashiCorp inc.

Components use

1. eureka

The server configuration

Pom reference < dependency > < groupId > org. Springframework. Cloud < / groupId > <artifactId> Spring-cloud-starter-eureka-server </artifactId> </dependency> yML configure eureka: instance: hostname: localhost instance-id: localhost:${server.port}
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/ eureka server: renewalPercentThreshold: 0.49 renewalThresholdUpdateIntervalMs: 180000# 3mins
    #peerEurekaNodesUpdateIntervalMs: 500
Copy the code

The springbootapplication startup class joins @enableeurekaserver

The client configuration

Pom reference < dependency > < groupId > org. Springframework. Cloud < / groupId > <artifactId> spring-cloud-starter-network-eureka-client </artifactId> </dependency> yML config eureka: client: service-url: defaultZone: http://localhost:10001/eurekaCopy the code

The springbootapplication startup class joins @enableeurekaserver and starts the server directly.

2. nacos

Server configuration:

Unzip nacos-server-version.tar.gz

cd nacos/bin

sh startup.sh -m standalone

The client configuration:

Pom reference < dependency > < groupId > org. Springframework. Cloud < / groupId > < artifactId > spring - the cloud - starter - alibaba - nacos - discovery < / artifactId > < version >. 0.9.0 RELEASE < / version > < / dependency > Yml configuration Spring: Application: name: nacos-demo Cloud: nacos: Discovery: server-addr: 127.0.0.1:8848 Management: EndPoints: web: exposure: include:The '*'
Copy the code

The springbootapplication startup class joins @enableeurekaclient.

3. consul

Server configuration:

Official address to download and launch

Enable consul agent-advertise 127.0.0.1 -data-dir=/ TMP/consul-server-bootstrap on a single node

The client configuration

Pom reference < dependency > < groupId > org. Springframework. Cloud < / groupId > <artifactId> Spring-cloud-starter-y-y-discovery </artifactId> <version>2.1.1.RELEASE</version> </dependency> YML configuration Spring: Application: name: consul-provider cloud: consul: host: 127.0.0.1 port: 8500 Discovery: Register:true
        service-name: consul-provider
Copy the code

The springbootapplication startup class joins @enableeurekaclient.

Use the compare

The dimension eureka nacos consul
Community ecology High community heat Low community heat, many Chinese documents High community heat
performance The 8-core 16GB server periodically polls, queries, and updates. When the number of services is too large (8000-10000), the pressure is too great 8-core 16 GB The hardware load is too high when a node with more than 9000 nodes is connected no
Cap distributed characteristics AP availability and partition fault tolerance; Availability: There are no primary and secondary nodes. If a node fails, it will automatically switch to other nodes. However, the service lists of different registry nodes may be inconsistent, which is acceptable AP or CP CP: As a distributed cluster, CP
Maintaining state 1.X stops maintenance. Version 2.0 closed source Recently open source; Only to 0.9.0 release; I have been maintaining with Spring Cloud until 2.1.1
Key functions, features 1. Springcloud-starter service, out of the box 2. A console 1. Support SpringCloud service discovery and configuration management; 2. Have Web UI console; 3 There’s a console; Disadvantages: There is no consul cluster configuration mode available, that is, the service cannot register multiple Consul nodes
Registered to use The service sends its service information to the Eureka server during registration. Service Renewals services to the Eureka server every 30 seconds. Service pulls the service list to the local cache every 30 seconds. Also keep the registry active by using the service to continuously report heartbeats; Service discovery. Constantly query the available service instances from the server. Notify the service holder of the query task from the changed service queue and update the local service list when the service changes. Supports both active consul check on the status of consul services and active service heartbeat reports to Consul about their health status.
other K8s integration, DuBBO integration are supported

summary

Eureka, Nacos, and Consul all support microservice registration and the most basic requirements of the Web UI console. However, Eureka is currently closed open source and Consul does not support client configuration registry clusters.