Spring Cloud or Dubbo for Microservices?

Click to follow  asynchronous books , stick to the public number

Share IT good books, technical dry goods and workplace knowledge with you every day

Participate in the topic discussion at the end of the article, and give asynchronous books every day.

- Asynchronous editor

In Alibaba's ecosystem, microservices have gradually become the main service form. With the maturity of containerization, a large number of distributed and domain-driven microservices have been rapidly developed and deployed, and services have shown the ability to build building blocks. Different businesses can realize new business scenarios by recombining several microservices. With the help of mature underlying group middleware, it naturally supports the dynamic scaling, service discovery, full-link log analysis and other capabilities required by microservices. Taking the voice dialogue platform of Alibaba Dharma Academy as an example, the dialogue service, understanding service, question and answer service, and dialogue management platform are all based on SpringBoot and Docker technology stack.

Features that Microservices Should Have

Microservices can be divided into the words "micro" and "service". "Micro" means small, so how small is "micro"? Different teams may have different answers. In terms of the number of people participating in microservices, the total number of people involved in architecture design, code development, testing, and operation and maintenance for a single microservice is 8 to 10 people who are considered "micro". So what is "service"? According to the definition given by Martin Fowler, who proposed the concept of "microservice": "service" is an independent unit component, each unit component runs in an independent process, and the lightweight HTTP is usually used between components. communication mechanism for communication.

Microservices have the following characteristics.

  • Divide services according to business. A single service has a small amount of code, a single business, and is easy to maintain.

  • Each microservice has its own independent basic components, such as database, cache, etc., and runs in an independent process.

  • Communication between microservices is through the HTTP protocol or message components, and is fault-tolerant.

  • Microservices have a set of service governance solutions, services are not coupled, and services can be added and removed at any time. A single microservice can be deployed in a cluster and has load balancing capabilities.

  • The entire microservice system should have a complete security mechanism, including user verification, permission verification, resource protection, etc.

  • The entire microservice system has the ability to track links.

  • There is a complete real-time log system.

Microservices have the above characteristics, so what kind of functions do microservices need to have? The functions are mainly reflected in the following aspects.

  • Registration and discovery of services.

  • Load balancing of services.

  • Service fault tolerance.

  • Service Gateway.

  • Unified management of service configuration.

  • Link tracking.

  • Live log.

Dubbo

Alibaba open-sourced the Dubbo framework in 2011. Although it stopped updating in 2013, it restarted maintenance and released a new version in September 2017. At present, many companies have built their businesses on Dubbo. At the same time, Alibaba Cloud has also launched EDAS, an enterprise-level distributed application service, to provide application hosting for Dubbo.

Dubbo uses Zookeeper as the registry and RPC as the service invocation method, and is committed to providing a high-performance and transparent RPC remote service invocation scheme. It integrates seamlessly with Spring, and builds a simple model based on the roles of service provider (server) and service caller (client). Its advantages are easy to use and low learning cost.

① The service provider publishes the service to the service registry.

② The service consumer subscribes to the service from the service registration center.

③ The registration center notifies the message caller that the service has been registered.

④ The service consumer invokes the registered available service.

⑤ Monitor the count.

Spring Cloud

Spring Cloud is implemented based on Spring Boot and uses HTTP RESTful API as the calling method. The multiple sub-projects it contains together build a microservice architecture system.

Netflix Eureka

Spring Cloud's service registry provides functions such as service registration, service discovery, and load balancing.


Netflix Hystrix

When a service fails, the circuit breaker mechanism (Hystrix) is triggered to return the result identification error to the service caller, instead of waiting for the service provider to return the result, so that the thread will not be occupied for a long time due to calling the faulty service. Release, to avoid the spread of faults in the distributed system.

Netflix Zuul

Proxy the services provided by each module and expose it to third-party applications uniformly. Provide dynamic routing, monitoring, elasticity, and congruent edge services.


Config Server

Multiple microservices in a distributed architecture will generate a lot of configuration files. The distributed configuration center (Config Server) will hand over all configuration files to GIT or SVN for unified management to avoid errors.


Spring Boot

在使用Spring开发时,通常需要完成Spring框架及其他第三方工具配置文件的编写,非常麻烦。Spring Boot通过牺牲项目的自由度来减少配置的复杂度,约定一套规则,把这些框架都自动配置集成好,从而达到“开箱即用”。

Spring Clould与Dubbo比较

首先从微服务关注点来比较Spring Cloud和Dubbo两大服务框架,如表1所示。

表1 从微服务关注点比较Spring Cloud和Dubbo

Spring Cloud拥有很多的项目模块,包含了微服务系统的方方面面。Dubbo是一个非常优秀的服务治理和服务调用框架,但缺少很多功能模块,例如网关、链路追踪等。在项目模块上,Spring Cloud占据着更大的优势。

Spring Cloud的更新速度非常块,Camden.SR5版本发布于2017年2月6日,Camden.SR6版本发布于2017年3月10日,Dalston版本发布于2017年4月12日,基本每个月会发一次版本的迭代。从GitHub的代码仓库来看,Spring Cloud几乎每天都有更新。阿里巴巴于2011年10月开源了Dubbo,开源后的Dubbo发展迅速,大概每2~3个月有一次版本更新。然而,从在2013年3月开始,Dubbo暂停了版本更新,并只在2014年10月发布了一个小版本,修复了一个bug,之后长期处于版本停止更新的状态。直到2017年9月,阿里巴巴中间件部门重新组建了Dubbo团队,把Dubbo列为重点开源项目,并在2017年9~11月期间,一直保持每月一次版本更新的频率。

从学习成本上考虑,Dubbo的版本趋于稳定,文档完善,可以即学即用,没有太大难度。Spring Cloud 基于Spring Boot开发,需要开发者先学会Spring Boot。另外,Spring Cloud版本迭代快,需要快速跟进学习。Spring Cloud文档大多是英文的,要求学习者有一定的英文阅读能力。此外,Spring Cloud文档很多,不容易快速找到相应的文档。

从开发风格上来讲,Dubbo 更倾向于Spring Xml的配置方式,Dubbo官方也推荐这种方式。Spring Cloud基于Spring Boot,Spring Boot采用的是基于注解和JavaBean配置方式的敏捷开发。从开发速度上讲,Spring Cloud具有更高的开发和部署速度。

最后,Spring Cloud 的通信方式大多数是基于HTTP Restful风格的,服务与服务之间完全无关、无耦合。由于采用的是HTTP Rest,因此服务无关乎语言和平台,只需要提供相应API接口,就可以相互调用。Dubbo 的通信方式基于远程调用,对接口、平台和语言有强依赖性。如果需要实现跨平台调用服务,需要写额外的中间件,这也是Dubbo存在的原因。

Dubbo和Spring Cloud拥有各自的优缺点。Dubbo更易上手,并且广泛使用于阿里巴巴的各大站点,经历了“双11”期间高并发、大流量的检验,Dubbo框架非常成熟和稳定。Spring Cloud服务框架严格遵守Martin Fowler 提出的微服务规范,社区异常活跃,它很可能成为微服务架构的标准。

微服务必读书

《深入理解Spring Cloud与微服务构建》

方志朋 著

点击封面购买纸书


CSDN博客专家、Spring Cloud中国社区联合创始人全新作品。

本书共分16章,全面涵盖了Spring Cloud构建微服务相关的知识点。第1、2章详细介绍了微服务架构和Spring Cloud。第3、4章讲解了用Spring Cloud构建微服务的准备工作。第5~12章以案例为切入点,讲解了Spring Cloud构建微服务的基础组件,包括Eureka、Ribbon、Feign、Hystrix、Zuul、Config、Sleuth、Admint等组件。第13~15章讲述了使用Spring Cloud OAuth2来保护微服务系统的相关知识。第16章用一个综合案例,全面讲解了如何使用Spring Cloud构建微服务,可以作为实际开发的样例工程。


《微服务分布式构架开发实战》

龚鹏 著 

点击封面购买纸书

为了更快地实施微服务,本书基于开源且稳定的第三方工具,介绍如何构建一个庞大且复杂的分布式系统,用于满足项目中的实际需求。每一个工具库为了适应更丰富的使用场景,通常都会把部分参数以配置文件的方式暴露出来,同时提供用于开发环境的默认配置。本书基于快速使用为主线路,尽可能多地讲解配置参数的意义及之间的关系。在掌握足够多的知识点后建立起对微服务分布式架构的认知,以便为探求更深层次的知识点做好铺垫。

本书适合Java工程师、初级架构师、大中专院校相关专业师生、Java培训班学员及独立开发者与自学读者使用。

今日互动

针对微服务你有哪方面的问题急需解决?或者试读图书说说你的感受?截止时间5月3日17时, 留言+转发本活动到朋友圈,小编将抽奖选出 5名读者 赠送e读版100元异步社区代金券一张,(留言点赞最多的自动获得一张)。

推荐阅读

2018年4月新书书单

异步图书最全Python书单

一份程序员必备的算法书单

第一本Python神经网络编程图书


长按二维码,可以关注我们哟

每天与你分享IT好文。


在“异步图书”后台回复“关注”,即可免费获得2000门在线视频课程;推荐朋友关注根据提示获取赠书链接,免费得异步e读版图书一本。赶紧来参加哦!

点击阅读原文,查看更多

阅读原文


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324956763&siteId=291194637