| 两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
|
服务器技术:微服务:dubbo和spring_cloud微服务架构对比 [2018/08/29 11:50] admin |
服务器技术:微服务:dubbo和spring_cloud微服务架构对比 [2018/09/10 18:02] (当前版本) |
||
|---|---|---|---|
| 行 23: | 行 23: | ||
| 通过 Dubbo 提供的负载均衡机制自动完成。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">Service:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">原子服务,只提供该业务相关的原子服务。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">Zookeeper:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">原子服务注册到 | 通过 Dubbo 提供的负载均衡机制自动完成。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">Service:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">原子服务,只提供该业务相关的原子服务。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">Zookeeper:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">原子服务注册到 | ||
| ZK 上。</span></p></li></ul><p style="clear:both;min-height:1em;text-align:center;line-height:2em;"><img src="https://img-blog.csdn.net/20171127162048355" alt=""/></p><p style="clear:both;min-height:1em;text-align:center;line-height:2em;"><span style="font-size:14px;"><span style="color:rgb(89,89,89);letter-spacing:1px;">Spring | ZK 上。</span></p></li></ul><p style="clear:both;min-height:1em;text-align:center;line-height:2em;"><img src="https://img-blog.csdn.net/20171127162048355" alt=""/></p><p style="clear:both;min-height:1em;text-align:center;line-height:2em;"><span style="font-size:14px;"><span style="color:rgb(89,89,89);letter-spacing:1px;">Spring | ||
| - | Cloud 组件运行</span></span></p><p style="clear:both;min-height:1em;line-height:2em;"><br/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;"></span></p><p><span style="display:block;background-color:rgb(89,89,89);"></span><span style="display:block;background-color:rgb(89,89,89);"></span><span style="display:block;background-color:rgb(89,89,89);"></span></p><p style="clear:both;min-height:1em;">Spring Cloud</p><p style="clear:both;min-height:1em;line-height:2em;"><br/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;letter-spacing:1px;color:rgb(71,193,168);">Spring Cloud组件运行:</span></p><ul class=" list-paddingleft-2"><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">所有请求都统一通过 API 网关(Zuul)来访问内部服务。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">网关接收到请求后,从注册中心(Eureka)获取可用服务。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">由 Ribbon 进行均衡负载后,分发到后端的具体实例。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">微服务之间通过 Feign 进行通信处理业务。</span></p></li></ul><p style="clear:both;min-height:1em;line-height:1.75em;"><br/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">点评:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">业务部署方式相同,都需要前置一个网关来隔绝外部直接调用原子服务的风险。</span></p><p style="clear:both;min-height:1em;line-height:2em;"><br/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">Dubbo 需要自己开发一套 API 网关,而 Spring Cloud 则可以通过 Zuul 配置即可完成网关定制。使用方式上 Spring Cloud 略胜一筹。</span></p><p style="clear:both;min-height:1em;line-height:2em;"><br/></p><h2 style="font-weight:400;font-size:16px;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;"></span></h2><p style="clear:both;min-height:1em;">微服务架构组成以及注意事项</p><h2 style="font-weight:400;font-size:16px;line-height:2em;"><br/></h2><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">到底使用是 Dubbo 还是 Spring Cloud 并不重要,重点在于如何合理的利用微服务。</span></p><p style="clear:both;min-height:1em;line-height:2em;"><br/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;letter-spacing:1px;color:rgb(71,193,168);">下面是一张互联网通用的架构图,其中每个环节都是微服务的核心部分。</span></p><p style="clear:both;min-height:1em;text-align:center;line-height:2em;"><img src="https://img-blog.csdn.net/20171127162056684" alt=""/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;letter-spacing:1px;color:rgb(71,193,168);">架构分解:</span></p><ul class=" list-paddingleft-2"><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">网关集群:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">数据的聚合、实现对接入客户端的身份认证、防报文重放与防数据篡改、功能调用的业务鉴权、响应数据的脱敏、流量与并发控制等。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">业务集群:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">一般情况下移动端访问和浏览器访问的网关需要隔离,防止业务耦合。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">Local Cache:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">由于客户端访问业务可能需要调用多个服务聚合,所以本地缓存有效的降低了服务调用的频次,同时也提示了访问速度。本地缓存一般使用自动过期方式,业务场景中允许有一定的数据延时。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">服务层:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">原子服务层,实现基础的增删改查功能,如果需要依赖其他服务需要在 | + | Cloud 组件运行</span></span></p><p style="clear:both;min-height:1em;line-height:2em;"><br/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;"></span></p><p><span style="display:block;background-color:rgb(89,89,89);"></span><span style="display:block;background-color:rgb(89,89,89);"></span><span style="display:block;background-color:rgb(89,89,89);"></span></p><p style="clear:both;min-height:1em;">Spring Cloud</p><p style="clear:both;min-height:1em;line-height:2em;"><br/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;letter-spacing:1px;color:rgb(71,193,168);">Spring Cloud组件运行:</span></p><ul class=" list-paddingleft-2"><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">所有请求都统一通过 API 网关(Zuul)来访问内部服务。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">网关接收到请求后,从注册中心(Eureka)获取可用服务。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">由 Ribbon 进行均衡负载后,分发到后端的具体实例。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">微服务之间通过 Feign 进行通信处理业务。</span></p></li></ul><p style="clear:both;min-height:1em;line-height:1.75em;"><br/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">点评:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">业务部署方式相同,都需要前置一个网关来隔绝外部直接调用原子服务的风险。</span></p><p style="clear:both;min-height:1em;line-height:2em;"><br/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">Dubbo 需要自己开发一套 API 网关,而 Spring Cloud 则可以通过 Zuul 配置即可完成网关定制。使用方式上 Spring Cloud 略胜一筹。</span></p><p style="clear:both;min-height:1em;line-height:2em;"><br/></p><h2 style="font-weight:400;font-size:16px;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;"></span></h2><p style="clear:both;min-height:1em;">微服务架构组成以及注意事项</p><h2 style="font-weight:400;font-size:16px;line-height:2em;"><br/></h2><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">到底使用是 Dubbo 还是 Spring Cloud 并不重要,重点在于如何合理的利用微服务。</span></p><p style="clear:both;min-height:1em;line-height:2em;"><br/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;letter-spacing:1px;color:rgb(71,193,168);">下面是一张互联网通用的架构图,其中每个环节都是微服务的核心部分。</span></p><p style="clear:both;min-height:1em;text-align:center;line-height:2em;"><br/></p><p style="clear: both; min-height: 1em; line-height: 2em;"><img src="/dokuwiki/ueditor/php/upload/image/20180829/1535521816343820.png" title="1535521816343820.png" alt="图片.png"/><img src="https://img-blog.csdn.net/20171127162056684" alt=""/></p><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;letter-spacing:1px;color:rgb(71,193,168);">架构分解:</span></p><ul class=" list-paddingleft-2"><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">网关集群:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">数据的聚合、实现对接入客户端的身份认证、防报文重放与防数据篡改、功能调用的业务鉴权、响应数据的脱敏、流量与并发控制等。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">业务集群:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">一般情况下移动端访问和浏览器访问的网关需要隔离,防止业务耦合。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">Local Cache:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">由于客户端访问业务可能需要调用多个服务聚合,所以本地缓存有效的降低了服务调用的频次,同时也提示了访问速度。本地缓存一般使用自动过期方式,业务场景中允许有一定的数据延时。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">服务层:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">原子服务层,实现基础的增删改查功能,如果需要依赖其他服务需要在 |
| Service 层主动调用。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">Remote Cache:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">访问 | Service 层主动调用。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">Remote Cache:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">访问 | ||
| DB 前置一层分布式缓存,减少 DB 交互次数,提升系统的TPS。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">DAL:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">数据访问层,如果单表数据量过大则需要通过 | DB 前置一层分布式缓存,减少 DB 交互次数,提升系统的TPS。</span></p></li><li><p style="clear:both;min-height:1em;text-align:justify;line-height:2em;"><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">DAL:</span><span style="font-size:15px;color:rgb(89,89,89);letter-spacing:1px;">数据访问层,如果单表数据量过大则需要通过 | ||