Essence! Comparison of selection of distributed configuration center Zookeeper SpringCloud-Config and Apollo configuration center

1. Advantages of Configuration Center

  • 1. Centralized management of each environment configuration
  • 2. Configuration changes are pushed in real time, and jvm environment variables take effect in time.
  • 3. Rely on configuration changes and dynamically expand functions to reduce the cost of the second launch.
  • 4. Reduce the extra overhead caused by developers and operation and maintenance personnel to modify the configuration.

Two, SpringCloud Config + SpringCloud Bus as the configuration center and message bus

The official structure chart:

Insert picture description here

2.1 Server server description

实例一般多于两个,以实现HA;

配置以文件形式存储,快速支持目前以SpringBoot的开发方式的配置文件;
支持GIt,码云,SVN,本地文件等多种形式;
支持属性加密;

2.2 Client client description

即各自的微服务应用;

使用SpringCloud BUS配置和借助Git仓库的WebHooks自动刷新;

2.3 spring-config flow chart

Insert picture description here
Flow Description:

  • 1 Store our remote configuration file on git
  • 2 config-server connect to git
  • 3 config-client connects to config-server
  • 4 When we start the config-client service, the client will get the configuration file on the remote git through the connected config-server, and then load it into the object through Spring.

2.4 spring-config features

1、存储位置
支持GIt,码云,SVN,本地文件等多种形式

2、数据实时更新方式
Cloud Bus(支持配置实时推送)

3、文件存储形式
以文件形式存储

三、Spring Cloud Zookeeper Config

Schematic diagram of zookeeper as a distributed configuration center

Insert picture description here

3.1 Election Leader Algorithm

When talking about zookeeper, I have to talk about the election algorithm of zookeeper:
first look at the schematic diagram
Insert picture description here
Insert picture description here

Detailed description of the leader election algorithm:

1、 当leader挂了后,其他非observer的机器变更状态为looking,然后开始选举流程 

2、每个server都会发出一个投票信息(myid,zxid) 

3、接收来自各个服务器的投票 

4、处理投票–判断zxid,大的zxid成为leader,如果zxid相同,就判断myid,myid大的做leader
 
5、统计投票–半数服务器达成一致意见后,投票结束 

6、改变自身的状态–leader为leading,其他服务器为following

3.2 The characteristics of Zookeeper as a configuration center

  • 3.2.1 Configuration interface zkui
1、实现对 zookeeper(包括集群节点的监控与管理)属性的CRUD操作。    
2、导出 zookeeper 的属性。    
3、通过回调地址实现对属性的导入操作。    
4、通过文件上传实现属性的导入。    
5、zkui提供了对属性值的搜索功能。    
6、Rest API用于访问 Zookeeper 属性。    
7、基于角色的基本认证。    
8、支持LDAP身份验证。    
9、zkui将zookeeper的根节点/ 进行了隐藏的处理,对于 zookeeper来说是安全的。    
10、ACL支持全局访问控制。
  • 3.2.2 Hot Update
ZooKeeper的Watch特性,配置信息变化实时推送到客户端,即时生效,无需重启客户端,达到配置热更新的效果
  • 3.2.3 Other functions of zookeeper
分布式锁
配置维护
组服务
分布式消息队列
分布式通知/协调等

4. Ctrip Apollo Configuration Center-the most comprehensive configuration center

Schematic diagram of the process of Apollo Configuration Center:
Insert picture description here

4.1 Process description of Apollo Configuration Center

Insert picture description here

上图简要描述了Apollo的总体设计,我们可以从下往上看:
● Config Service提供配置的读取、推送等功能,服务对象是Apollo客户端

● Admin Service提供配置的修改、发布等功能,服务对象是Apollo Portal(管理界面)

● Config Service和Admin Service都是多实例、无状态部署,所以需要将自己注册到Eureka中并保持心跳
在Eureka之上我们架了一层Meta Server用于封装Eureka的服务发现接口

● Client通过域名访问Meta Server获取Config Service服务列表(IP+Port),而后直接通过IP+Port访问服务,同时在Client侧会做load balance、错误重试

● Portal通过域名访问Meta Server获取Admin Service服务列表(IP+Port),而后直接通过IP+Port访问服务,同时在Portal侧会做load balance、错误重试

●为了简化部署,我们实际上会把Config Service、Eureka和Meta Server三个逻辑角色部署在同一个JVM进程中

4.2 Features of Apollo Configuration Center

  • 1 Unified management of the configuration of different environments and different clusters
    Apollo provides a unified interface to centrally manage the configuration of different environments, different clusters, and different namespaces.
    The same code is deployed in different clusters and can have different configurations, such as the address of zookeeper, etc.
    Through the namespace (namespace), it is easy to support multiple different applications to share the same configuration, and at the same time allow the application to overwrite the shared configuration

  • 2 Configuration modification takes effect in real time (hot release) After the
    user has modified the configuration and released it in Apollo, the client can receive the latest configuration in real time (1 second) and notify the application

  • 3 Version release management
    All configuration releases have a version concept, which can easily support configuration rollback

  • 4 Gray release
    Supports configured gray release. For example, after clicking release, it will only take effect for some application instances. After observing for a period of time, there is no problem before pushing to all application instances.

  • 5 Authority management, release review, operation audit The
    application and configuration management has a complete authority management mechanism, and the configuration management is divided into two links: editing and publishing, thereby reducing human errors.
    All operations have audit logs for easy tracking of problems

  • 6 Client configuration information monitoring
    You can easily see which instances the configuration is being used on the interface

  • 7 Provide Java and .Net native clients
    Provide Java and .Net native clients to facilitate application integration.
    Support Spring Placeholder, Annotation and Spring Boot ConfigurationProperties to facilitate application use (requires Spring 3.1.1+)
    and also provides Http interface , Non-Java and .Net applications can also be used easily

  • 8 Provide open platform API
    Apollo itself provides a relatively complete unified configuration management interface, which supports features such as multi-environment, multi-data center configuration management, permissions, and process governance. However, for versatility, Apollo will not restrict the modification of the configuration too much. As long as it conforms to the basic format, it can be saved. It will not perform targeted verification for different configuration values, such as database user names, passwords, and Redis. Service address, etc.
    For this kind of application configuration, Apollo supports the application side to modify and publish the configuration in Apollo through the open platform API, and has complete authorization and permission control.

  • 9 Simple deployment The
    configuration center, as a basic service, has very high availability requirements, which requires Apollo to rely as little as possible on external sources.

Five, summary

First look at the comparison chart of each configuration center
Insert picture description here
Insert picture description here

5.1 Select zookeeper as the configuration center

在SpringCloud项目中,官方推荐使用SpringCloud Config + SpringCloud Bus作为配置中心和消息总线,  但是缺少管理页面,实时更新也不是很方便.  在实际运用的时候,一些简单快速的做法也能达到类似的效果, 如采用zookeeper配置中心

优点:
1 满足常用的配置中心的功能, 包括服务器启动的配置文件和实时的数据更新
2 功能相对比较简单, 维护成本低
3 kafka与zookeeper绑定的比较紧密
缺点:
1 不够专业
2  功能比较简单

5.2 Select Apollo as the configuration center

优点: 

携程的Apollo 功能强大完善,github上开源社区比较活跃,代码一直在维护,而且文档写得清楚

缺点:

因为更加全面,使用起来也相对麻烦一些。

Six, the author has something to say

Most of the programmers are programming for Baidu or Google, and the information on the Internet is messy, sometimes it is uncomfortable to find, so I collect data for free, most of the information is collected and tested by myself. However, you don’t have to doubt the accuracy. However, your ability is limited and avoid omissions. I hope that readers can make corrections in comments or private messages, and everyone can contribute to Internet technology together.


Collecting information is boring. If this article is helpful to you, you can like it. This is also my greatest encouragement and praise.

Can I change my name or my surname? The Chaoshan’s Cancan Exhibition

Determined to make your own contribution in the Internet industry


Guess you like

Origin blog.csdn.net/qq_34168515/article/details/109253747