---
title: "Spring Cloud 二代组件"
description: "先来看一下第一代 spring cloud 的组件组件名称功能描述Eureka服务治理（注册、发现....."
date: 2020-07-22T23:00:00Z
canonical: https://xiaobox.github.io/p/2020-07-22-spring-cloud-er-dai-zu-jian/
author: 小盒子
categories: ["云原生"]
tags: ["Spring", "Cursor"]
source: https://mp.weixin.qq.com/s/7fh5b73ct5yvzsm_cWCu2A
license: CC BY-NC-SA 4.0
license_url: https://creativecommons.org/licenses/by-nc-sa/4.0/
---

# Spring Cloud 二代组件

![Image](https://pub-f29bf2b53160470c9a85250116509a24.r2.dev/post/2020-07-22-spring-cloud-er-dai-zu-jian/001-5a56e50e.jpg)

### 先来看一下第一代 spring cloud 的组件

<table style="visibility: visible;"><tbody style="visibility: visible;"><tr style="visibility: visible;"><td style="min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;"><p data-lake-id="80194537a7a8305345072ad8f4ea294e_p_0" style="font-size: 15px; color: rgb(64, 64, 64); line-height: 1.74; letter-spacing: 0.008em; outline-style: none; visibility: visible;">组件名称</p></td><td style="min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;" width="168"><p data-lake-id="fe91734e59baf7bf70096abd557f6c7b" style="font-size: 15px; color: rgb(64, 64, 64); line-height: 1.74; letter-spacing: 0.008em; outline-style: none; visibility: visible;">功能</p></td><td rowspan="1" style="vertical-align: top; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;" width="264"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px; line-height: 1.74; letter-spacing: 0.008em; outline-style: none; visibility: visible;">描述</p></td></tr><tr style="visibility: visible;"><td colspan="1" rowspan="1" style="vertical-align: top; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;"><span style="color: rgb(26, 26, 26); visibility: visible;">Eureka</span></td><td colspan="1" style="vertical-align: top; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;" width="39"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px; line-height: 1.74; letter-spacing: 0.008em; outline-style: none; visibility: visible;">服务治理（注册、发现......）</p></td><td rowspan="1" style="vertical-align: top; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;" width="260"><br style="visibility: visible;"></td></tr><tr style="visibility: visible;"><td style="min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;"><p data-lake-id="af68ace328ceba1fee2cc254f0d23cb3" style="font-size: 15px; color: rgb(64, 64, 64); line-height: 1.74; letter-spacing: 0.008em; outline-style: none; visibility: visible;"><span style="color: rgb(26, 26, 26); visibility: visible;">Ribbon</span></p></td><td style="min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;" width="39"><p data-lake-id="ab0729b1373a400ab8ff4f5dc8f7ae48" style="font-size: 15px; color: rgb(64, 64, 64); line-height: 1.74; letter-spacing: 0.008em; outline-style: none; visibility: visible;">客户端负载均衡器</p></td><td rowspan="1" style="vertical-align: top; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;" width="260"><br style="visibility: visible;"></td></tr><tr style="visibility: visible;"><td style="min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;"><p data-lake-id="ad6208b5d932566be6bdd6d50e6d594b" style="font-size: 15px; color: rgb(64, 64, 64); line-height: 1.74; letter-spacing: 0.008em; outline-style: none; visibility: visible;"><span style="color: rgb(26, 26, 26); visibility: visible;">Hystrix</span></p></td><td style="min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;" width="39"><p data-lake-id="4a2ed31e9a0e01248f12f39ebb8bed27" style="font-size: 15px; color: rgb(64, 64, 64); line-height: 1.74; letter-spacing: 0.008em; outline-style: none; visibility: visible;"><span style="color: rgb(26, 26, 26); visibility: visible;">服务之间远程调用时的熔断保护</span></p></td><td rowspan="1" style="vertical-align: top; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;" width="260"><p data-lake-id="fb0fe7dea25afd456b161b0cce972d58" style="font-size: 15px; line-height: 1.74; letter-spacing: 0.008em; outline-style: none; visibility: visible;">Hystrix 的使用主要有三种方式</p><ul data-lake-id="9be4695ce9ec75644d1e3011d09abe0a" lake-indent="0" style="padding-left: 23px; font-size: 15px; line-height: 1.74; letter-spacing: 0.008em; outline-style: none; visibility: visible;" class="list-paddingleft-2"><li style="visibility: visible;"><p style="visibility: visible;">HystrixCommand 注解方式</p></li><li style="visibility: visible;"><p style="visibility: visible;">结合 Feign 使用</p></li><li style="visibility: visible;"><p style="visibility: visible;">结合 Zuul 使用</p></li></ul></td></tr><tr style="visibility: visible;"><td style="min-width: 90px; font-size: 14px; white-space: normal; border-color: rgb(217, 217, 217); padding: 4px 8px; cursor: default; visibility: visible;"><p data-lake-id="621646e47c4e9970932d19464eac24e6" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><span style="color: #1A1A1A;">Feign</span></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;" width="39"><p data-lake-id="68cd6efa8271dd3be836728eaf6df4d2" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><span style="color: #1A1A1A;">通过定义接口的方式直接调用其他服务的 API</span></p></td><td rowspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;" width="260"><br></td></tr><tr><td rowspan="1" colspan="1" style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><span style="color: #1A1A1A;background-color: #FFFFFF;">Zuul</span></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;" width="39"><p data-lake-id="323ac42010ffdff18e00de789eb09e73" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">服务网关</p></td><td rowspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;" width="260"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px;line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><span style="color: #1A1A1A;">提供了路由、监控、弹性、安全等服务。Zuul 能够与 Eureka、Ribbon、Hystrix 等组件配合使用。</span><span style="color: #1A1A1A;"></span></p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="cbe732ebd9bee93024748ab1f5ea3313" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><span style="color: #1A1A1A;">Config</span></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;" width="39"><p data-lake-id="a5835af68d3e37f9f6ef3a4cb50cbf9a" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">分布式配置中心组件</p></td><td rowspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;" width="260"><br></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="97b1c29d769b577a16de88e4361c7a1d" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><span style="color: #1A1A1A;">Sleuth</span></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;" width="39"><p data-lake-id="39e0d872f60052b645c8b4856a3178fc" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><span style="color: #1A1A1A;">用于请求链路跟踪</span></p></td><td rowspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;" width="260"><br></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="8ddb67ade7b70ed588dfb9a3d7abbede" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><span style="color: #1A1A1A;">Stream</span></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;" width="39"><p data-lake-id="8c5def182ad5e37cd834c21e7294fe18" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><span style="color: #1A1A1A;">用来为微服务应用构建消息驱动能力</span></p></td><td rowspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;" width="260"><br></td></tr></tbody></table>

spring cloud 现在已经是一种标准了，各公司可以基于它的编程模型编写自己的组件 ，比如Netflix、阿里巴巴都有自己的一套通过spring cloud 编程模型开发的分布式服务组件 。

Spring Cloud Alibaba 主要包含 Sentinel、Nacos、RocketMQ、Dubbo、Seata 等组件。

### Spring Cloud 二代组件

二代引入了 Spring Cloud Alibaba

<table width="720"><tbody><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="da7adf83307efeab48ba5fb7b7775b7d" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">第一代组件</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="e457b9be34990933dcdd9353415c73a4" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">第二代组件&nbsp;</p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="f8e82f8d1378d8fcaa5153e3ded3e4a0" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Eureka</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="6852b9944be304b3db1005b2252168ac" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Nacos</p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="d39342afd49c0d26d1b3de2bd4aca4c9" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Config</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="9c278c46be437054b308a085fee3b56c" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Apollo</p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="827bc9b52e8a943b56dc20dda2ee38ec" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Zuul</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="e3db44c2a6997fde52348be2e38950aa" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">spring cloud gateway</p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="483b1245c36ddeac58721367dd2f5153" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><span style="color: #1A1A1A;">Hystrix</span></p></td><td rowspan="1" colspan="1" style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><span style="color: #1A1A1A;background-color: #FFFFFF;">Sentinel</span></td></tr></tbody></table>

### Eureka VS Nacos

Eureka 之前官方也宣布了暂停了 2.X 版本的开发，1.X 的版本还会维护。其实对于一般的服务规模，目前的 Eureka 完全够用了。而 Nacos 作为后起之秀，目前更新频率很高，社区也更活跃，使用 Nacos 是一个正确的选择。

### **Apollo VS Spring Cloud Config**

<table width="720"><tbody><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="08ca20eb36284487001463292f6550f4_p_0" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">功能</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="f699b6228a0ee572bf4fb4d49a92b3a0_p_0" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><strong>spring cloud config</strong></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><strong>apollo</strong></p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="75c2d6da1a774b1f4f0fb5a7b075fed8" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><strong>统一配置管理</strong></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="e2a8391c6568b4f31e4eb38ea57664ee" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">集成Git</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="5c08561bbd4a3fb6e877e47d5253671d" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">自带存储(MySql)</p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="182ba122416a12429fb2e403d2e777a5" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><strong>多环境区分</strong></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="7934d0b36cffa69207615b37b2bcfe88" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">配置指定</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="83300f08c2492de01993efe9270ab6f5" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">配置指定</p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="cf9b2b88a75bdb890f556b4d7d40db9d" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><strong>实时更新</strong></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="4f963073e4510289e9074799a11352e0" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Bus消息总线</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="5c0d93298c1692596d2fdb9a1fb02d4d" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Http长连接</p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="80d17a3dbad4062088f98bb3533edf5f" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><strong>定时拉取</strong></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="474c32fea8037eeb75e8d46382da44d9" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">需要自己扩展</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="f06aaaefa43bcb620e4b64ad7d908dcb" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">支持</p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="2708ec55469155f6c79911ce3d06d610" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><strong>权限控制</strong></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="6f61c0e7120c265eb5ff8aef14639243" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">需要Git支持</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="f06aaaefa43bcb620e4b64ad7d908dcb" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">支持</p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="68fd0587102991d0caeef295bf1731f0" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><strong>版本管理</strong></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="2dfad04a50931b57ea8fb2e6479c25ce" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Git版本</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="ad359c29d8e0a3c76b96bfaeb86bf9c7" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">有直接的版本功能，一键恢复指定版本</p></td></tr><tr><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="e126e09ff42a23353723e1a7472a04d8" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;"><strong>Web管理后台</strong></p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="8994d22a85d63892f61bb4070180752d" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">无</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="b0ba5375ed2cf9f03df93c95d56dbc6c" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">有</p></td></tr></tbody></table>

### Zuul VS Spring Cloud Gateway

在 Spring Cloud Gateway 出现之前，网关都是用 Zuul 构建的，虽然 Netflix 开源了 Zuul2，由于各种原因，官方并没有打算将 Zuul2 集成到 Spring Cloud 体系中。而是自己研发了一个全新的网关 Spring Cloud Gateway，由于 Zuul1 基于 Servlet 构建，使用的是阻塞的 IO，性能并不是很理想。Spring Cloud Gateway 则基于 Spring 5、Spring boot 2 和 Reactor 构建，使用 Netty 作为运行时环境，比较完美的支持异步非阻塞编程。

官方提供的压测报告显示 Spring Cloud Gateway 的性能是 Zuul 的 1.5 倍，Spring Cloud Gateway 刚出不久，稳定性有待验证，主要是缺乏大规模流量的验证，而 Zuul 开源的时间较长，同时在 Netflix 内部经过了大规模流量的验证，比较稳定。长期发展来说，Spring Cloud Gateway 的优势比较大，毕竟官方主推。

### Hystrix VS Sentinel

Hystrix 替换成了 Sentinel，Hystrix 也停止了开发，这个时候 Spring Cloud Alibaba 中的 Sentinel 的优势就很明显了，Sentinel 支持多样化的流量控制，熔断降级等功能，完全可以替代 Hystrix。

### 其他

-   分布式事务：Seata

-   消息队列:     RocketMQ

-   调用链监控：Apache Skywalking

-   日志查询：  ELK

-   指标监控：  Prometheus

-   分布式缓存:  Redis

-   分布式定时任务：XXL-JOB

### 整体架构组件

基于以上，如果我来设计系统架构，那么将用以下组件

<table width="720"><tbody><tr style="height: 33px;"><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="d3020c672ae2ee43a925116d0a18ffd9" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">组件</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="debb046a77ddc13e221bc1724a743969" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">功能</p></td></tr><tr style="height: 33px;"><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="2767527654b770a2a13e0bf0059e4e8f" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Nacos</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a65adfa2370fc37d81315d1ae112ba5b" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">服务注册中心</p></td></tr><tr style="height: 33px;"><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="9b80dc3201e1f4080535a76ffffe1bba" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Apollo</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="e9a6a6fd67f072926c705fad87fb2274" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">分布式配置中心</p></td></tr><tr style="height: 33px;"><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="c1ab16fc16f20cef8a5d0dd70665328e" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">XXL-JOB</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="230863fde75ba47098ac62b2221c30c1" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">分布式定时任务中心</p></td></tr><tr style="height: 33px;"><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="f0e24ed067468681b2726d7c66480f3d" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">SpringBoot</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="eaf54c95b04b175aead6059ae0002c27" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">微服务组件&nbsp;</p></td></tr><tr style="height: 33px;"><td rowspan="1" colspan="1" style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Sentinel</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="d5dd9fe9869f8e04b7ce1c635f048d34" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">服务熔断限流组件&nbsp;</p></td></tr><tr style="height: 33px;"><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="dee654565952baa59f2cda14635e133b" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Spring Cloud Gateway</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="fc17c84741cef5cdfbbdf6f1de40d265" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">微服务网关</p></td></tr><tr style="height: 33px;"><td colspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px;line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Spring Cloud OpenFeign</p></td><td colspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px;line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">服务通信调用</p></td></tr><tr style="height: 33px;"><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="88ed8a1c6076d595d8db642b877bc547" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Seata</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="f0d95f76725f101effc49be3c95bb717" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">分布式事务</p></td></tr><tr style="height: 33px;"><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="7bae3ec8c7394383a9e4d08db54acc7a" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">RocketMQ</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a4799f138db5b969d2fbf173767f0551" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">消息队列</p></td></tr><tr style="height: 33px;"><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a84649f09678ab257425d2ffd241b210" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Skywalking</p></td><td style="min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="091839649de39e41dbf04bc42026a513" style="font-size: 15px;color: rgb(64, 64, 64);line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">服务调用链监控系统</p></td></tr><tr style="height: 33px;"><td colspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px;line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Redis</p></td><td colspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px;line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">分布式缓存&nbsp;</p></td></tr><tr style="height: 33px;"><td colspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px;line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">ELK</p></td><td colspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px;line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">日志收集、查询系统</p></td></tr><tr style="height: 33px;"><td colspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px;line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Prometheus</p></td><td colspan="1" style="vertical-align: top;background-color: rgb(255, 255, 255);color: rgb(64, 64, 64);min-width: 90px;font-size: 14px;white-space: normal;border-color: rgb(217, 217, 217);padding: 4px 8px;cursor: default;"><p data-lake-id="a20d224c568e48b9d67847a2c66a8c01_p_0" style="font-size: 15px;line-height: 1.74;letter-spacing: 0.008em;outline-style: none;">Metrics指标监控系统</p></td></tr></tbody></table>

**此外，微服务集群是以容器的方式部署的，用K8S进行docker集群管理。**

![Image](https://pub-f29bf2b53160470c9a85250116509a24.r2.dev/post/2020-07-22-spring-cloud-er-dai-zu-jian/002-3a0d7d8f.png)

![Image](https://pub-f29bf2b53160470c9a85250116509a24.r2.dev/post/2020-07-22-spring-cloud-er-dai-zu-jian/003-42df053f.jpg)

关注公众号 获取更多精彩内容

