Spring Cloud introduces Spring Cloud and Dubbo comparison

Spring Cloud is a cloud application development tool based on Spring Boot. It provides configuration management, service discovery, circuit breakers, intelligent routing, micro-agents, control buses, global locks, decision-making campaigns, distributed Operations such as session and cluster state management provide an easy way to develop.

Comparison of Spring Cloud and Dubbo
When it comes to Dubbo, I want to mention ESB by the way. CCTV Xinhua News Agency is also using ESB for task scheduling. Let’s compare Dubbo and ESB first:

ESB (Enterprise Data Bus) generally adopts centralized forwarding request, which is suitable for the integration of a large number of heterogeneous systems, and focuses on the arrangement of tasks. Performance problems can be avoided through heterogeneous methods, and cannot support particularly large concurrency.
Dubbo (service registration management) uses distributed calls. The registration center only records address information, and then makes direct calls, which is suitable for situations where concurrency and pressure are relatively high; The system completes the business arrangement in the program logic.

Returning to the topic, what is the difference between Spring Cloud and Dubbo? First, let's see what the similarities are. Both of them have functions related to distributed service governance, and both can provide service registration, discovery, routing, load balancing, etc. Speaking of which, Dubbo seems to have so many functions, but Spring Cloud is a perfect solution to provide a complete set of enterprise-level distributed cloud applications, which can be combined with Spring Boot and Docker to achieve rapid development, so Dubbo only has Spring Part of the RPC function of Cloud, and it's not good or bad. However, the Dubbo project has stopped updating, and Taobao has replaced dubbo with hsf. I think more people will tend to Spring Cloud.

From the development point of view, Dubbo is often combined with Spring and zookeeper, and the implementation only configures the service address, name, and port through xml. The intrusiveness of the code is very small. Compared with Spring Cloud, its implementation requires class annotations, etc., how many somewhat invasive.

Spring Cloud subproject

Spring Cloud includes multiple sub-projects (for multiple different open source products involved in distributed systems), which were also introduced in the first chapter, such as: Spring Cloud Config, Spring Cloud Netflix, Spring Cloud CloudFoundry, Spring Cloud AWS, For projects such as Spring Cloud Security, Spring Cloud Commons, Spring Cloud Zookeeper, and Spring Cloud CLI, you can skip to (1) to see.

configuration service
Spring Cloud provides Config Server, which has the function of external configuration in distributed system development. Through Config Server, we can centrally store the configuration files of all applications. Config Server supports Git or places configuration files in the file system (GitLab). Usually, we use different formats to distinguish different configuration files for different applications. In the cloud computing environment, it is customary to use YAML configuration, and the location of the general configuration file is placed in the config directory under the classpath. Configuration file rules: application name + profile.yml:

[html] view plain copy
/{application}/{profile}[/{label}]  
/{application}-{profile}.yml  
/{label}/{application}-{profile}.yml  
/{application}-{profile}.properties  
/{label}/{application}-{profile}.properties  
Spring Cloud provides the annotation @EnableConfigServer to start the configuration service.

service discovery
Spring Cloud implements service discovery through Eureka of Netflix OSS. The main purpose of service discovery is to allow each service to communicate with each other. Eureka Server is the registry of microservices. When it comes to Spring Cloud Netflix, it is one of the sub-projects of Spring Cloud. The main modules provided include: service discovery (Eureka), circuit breaker (Hystrix), smart road (Zuul), client load balancing (Ribbon), etc.
Spring Cloud provides Eureka server (@EnableEurekaServer) and client (@EnableEurekaClient) using annotations.

routing gateway
The main purpose of the routing gateway is to allow all microservices to have only one external interface. We only need to access one gateway address, and the gateway can proxy all requests to different services. Spring Cloud is implemented through Zuul and supports automatic routing mapping to services registered on Eureka Server. Spring Cloud provides the annotation @EnableZuulProxy to enable routing proxy.

load balancing
Spring Cloud provides Ribbon and Feign as client load balancing. Under Spring Cloud, you can use Ribbon to directly inject a RestTemplate object. This RestTemplate has been configured for load balancing; while using Feign, you only need to define an annotation, an interface annotated with @FeignClient, and then use the @RequestMapping annotation to map on the method For remote REST services, this method is also configured for load balancing.

breaker
Circuit Breaker is mainly to solve when a method fails to call a backup method to replace the failed method, which has achieved the function of fault tolerance/prevention of cascading errors. Spring Cloud uses @EnableCircuitBreaker to enable circuit breaker support and @HystrixCommand's fallbackMethod to specify fallback methods. (@HystrixCommand(fallbackMethod="fallbackOper"))
Spring Cloud also provides a console to monitor the operation of circuit breakers, enabled by the @EnableHystrixDashboard annotation.

Spring Cloud dependency library

Here I will list some commonly used dependency packages. In order to better understand the area responsible for each dependency, I still use a diagram similar to the previous one to show the functions of each block:

Common dependencies are as follows:

[html] view plain copy
spring-cloud-starter-parent has the same functionality as spring-boot-starter-parent and adds Spring Cloud dependencies  
spring-cloud-starter-config The default configuration service dependency, the way to quickly and automatically introduce services, port 8888  
spring-cloud-config-server/client User-defined configuration service server/client dependencies  
spring-cloud-starter-eureka-server Eureka Server dependencies for service discovery  
Eureka client dependencies for spring-cloud-starter-eureka service discovery  
spring-cloud-starter-hystrix/zuul/feign/ribbon circuit breaker (Hystrix), smart road (Zuul), client load balancing (Ribbon) dependencies  
angular-ui-router page distribution routing dependencies  
Summarize
All the summaries here just stay on the understanding of Spring Cloud. I recommend going to http://projects.spring.io/spring-cloud/ official website to read the multi-practice project, understand the service message communication method of each module, etc., probably That's it.
If you are interested in Spring Cloud, want to know about the rapid development of Spring Boot, and use JHipster to generate and build the application code of Spring Boot + AngularJS, welcome to join the QQ group: 58612944, there are many great guides in it, and I am also learning. In addition, in the group, we are organizing the translation of the official documents of JHipster on GitHub. If you are interested, you can come in and contribute to the open source.
About the JHipster extension
JHipster -> About the technology stack of SpringBoot, AngularJS and Spring ecological integration, it is the best practice of SpringBoot, it is the best practice of SpringCloud's technology stack for Netflix, it is the best practice of J2EE-Cloud microservices, it is Docker, Kubernetes and AngularJS1 The best practice of /2 is the most ideal tool for full-stack development and agile development.

Guess you like

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