Reprint: The difference between SpringCloud and Dubbo

This article is reproduced in: For the record only


1. The difference between SpringCloud and Dubbo

Both are now mainstream microservice frameworks , but there are many differences:

  • The initial positioning is different : SpringCloud is positioned as a one-stop solution under the microservice architecture; Dubbo is a product of the SOA era, and its focus is mainly on service invocation and governance
  • The ecological environment is different : SpringCloud relies on the Spring platform and has a more complete ecological system; while Dubbo only made RPC remote calls at the beginning, the ecology is relatively scarce, and now it is gradually enriched.
  • Call method : SpringCloud uses the Http protocol for remote calls, and the interface is generally in the Rest style, which is relatively flexible; Dubbo uses the Dubbo protocol, and the interface is generally a Java Service interface with a fixed format. However, Netty's NIO method is used when calling, and the performance is better.
  • There are many differences in components . For example, the SpringCloud registration center generally uses Eureka, while Dubbo uses Zookeeper

SpringCloud has rich ecology and complete functions, which is more like a brand machine, while Dubbo is relatively flexible and highly customizable, more like an assembly machine. Relevant information:

SpringCloud : Spring's open source microservice framework , SpirngCloud is positioned as a one-stop solution under the microservice architecture.

Dubbo : Alibaba's open source RPC framework. Dubbo is a product of the SOA era. Its focus is mainly on service invocation, traffic distribution, traffic monitoring, and circuit breaking.

SpringCloudAlibaba

Ecological comparison between the two:

Function Dubbo SpringCloud
Service Registry Zookeeper Eureka (mainstream), Consul, zookeeper
Service call method RPC is based on the Dubbo protocol REST API based on Http protocol
service monitoring Dubbo-Monitor Spring Boot Admin
fuse imperfect Spring Cloud Netflix Hystrix
service gateway none Spring Cloud Netflix Zuul、Gateway
distributed configuration none Spring Cloud Config
service tracking none Spring Cloud Sleuth+Zipkin (General)
data flow none Spring Cloud Stream
batch task none Spring Cloud Task
information bus none Spring Cloud Bus

The functions of Spring Cloud are obviously more powerful than Dubbo, and its coverage is wider. As the flagship project of Spring, it can also be perfectly integrated with other Spring projects such as Spring Framework, Spring Boot, Spring Data, and Spring Batch. These are for microservices. Words are crucial.

The microservice architecture built using Dubbo is like assembling a computer , with a high degree of freedom in the selection of each link, but the final result is likely to be unlit due to poor memory quality, which always makes people feel uneasy, but if the user is A master, then these are not problems.

And Spring Cloud is like a brand machine . Under the integration of Spring Source, a lot of compatibility tests have been done to ensure that the machine has higher stability. The principle has enough understanding.

2. The difference between dubbo and Feign remote calls

Feign is a remote calling method in Spring Cloud, based on the mature Http protocol, and all interfaces adopt the Rest style. Therefore, the interface specification is more unified, and as long as it conforms to the specification, the microservice that implements the interface can be developed in any language or technology. However, limited by the characteristics of the http protocol itself, the request and response formats are bloated, and its communication efficiency will be relatively poor.

The Dubbo framework adopts the Dubbo custom communication protocol by default, and the bottom layer is TCP communication like the Http protocol. However, the Dubbo protocol customizes Java data serialization and deserialization methods and data transmission formats, so Dubbo will be better than the Http protocol in terms of data transmission performance.

However, this performance difference does not need to be considered too much unless it reaches an extremely high level of concurrency.

Relevant information:

Dubbo uses the custom Dubbo protocol to realize remote communication, which is a typical RPC calling scheme, while Feign used in SpringCloud is based on the Rest-style calling method.

1) Rest style

REST is an architectural style that refers to a set of architectural constraints and principles. An application or design that satisfies these constraints and principles is RESTful.

The Rest style can be completely implemented through the HTTP protocol, using the HTTP protocol to handle data communication. The operations of the REST architecture on resources include acquiring, creating, modifying and deleting resources, exactly corresponding to the GET, POST, PUT and DELETE methods provided by the HTTP protocol.

Therefore, the process of requesting and wanting only needs to follow the http protocol, which is more flexible

Feign in Spring Cloud is a Rest-style calling method.

2)RPC

Remote Procedure Call, remote procedure call, is to call a remote method like a local method.
RPC generally needs to determine the following things:

  • Data transmission method: Most RPC frameworks choose TCP as the transmission protocol, which has better performance.
  • Data transmission content: The requester needs to inform the name, parameters, and other information of the function to be called.
  • Serialization method: When the client and the server interact, the parameters or results are converted into byte streams for transmission in the network, then data conversion into byte streams or conversion of byte streams into a fixed format that can be read needs to be done Serialization and deserialization

Because of the need for serialization and deserialization, there are strict requirements on the data transmission format, which is not as flexible as Http

The Dubbo protocol is a typical representative of RPC.

Let's look at the difference between Dubbo protocol and Feign call:

Dubbo Feign (Http call)
Transfer Protocol TCP TCP
Development language java unlimited
performance good generally
flexibility generally good

3. The difference between Eureka and Zookeeper registration center

Both SpringCloud and Dubbo support multiple registries, but currently SpringCloud uses Eureka more, while Dubbo mainly uses Zookeeper. There are big differences between the two:

  • From the perspective of cluster design: all nodes in the Eureka cluster are equal, and there is no master-slave relationship, so data inconsistency may occur; ZK must include a master-slave relationship in order to meet consistency, one master and many slaves. When the cluster has no owner, it does not provide external services
  • In terms of CAP principles: Eureka satisfies the AP principle, sacrificing the consistency of cluster data in order to ensure the availability of the entire service; and Zookeeper satisfies the CP principle, sacrificing the availability of the entire service in order to ensure the data consistency of each node.
  • In terms of service pull methods: Eureka adopts an active service pull strategy. Consumers go to Eureka to pull services at a fixed frequency (default 30 seconds) and cache them locally; consumers in ZK start to subscribe to ZK for the first time Service information, and cached locally. Then monitor the changes in the service list, and ZK will push the service changes to consumers in the future.

4. What are the common components in Spring Cloud?

There are many sub-projects of Spring Cloud, and the more common ones are Netflix open source components:

  • Spring Cloud Config
    centralized configuration management tool, unified external configuration management in distributed systems, uses Git to store configuration by default, and can support client configuration refresh, encryption, and decryption operations.

  • Spring Cloud Netflix
    Netflix OSS open source component integration, including Eureka, Hystrix, Ribbon, Feign, Zuul and other core components.

    • Eureka: Service governance components, including the registry on the server side and the service discovery mechanism on the client side;
    • Ribbon: load balancing service invocation component, with multiple load balancing invocation strategies;
    • Hystrix: service fault-tolerant component, which implements the circuit breaker mode and provides fault tolerance for errors and delays in dependent services;
    • Feign: A declarative service call component based on Ribbon and Hystrix;
    • Zuul: API gateway component, which provides routing and filtering functions for requests.
  • Spring Cloud Bus
    is a message bus used to propagate cluster state changes, using a lightweight message agent to link nodes in a distributed system, which can be used to dynamically refresh the service configuration in the cluster.

  • Spring Cloud Consul
    is based on the service governance component of Hashicorp Consul.

  • The Spring Cloud Security
    security toolkit supports the load balancing OAuth2 client and login authentication in the Zuul proxy.

  • Spring Cloud Sleuth
    Distributed request link tracing for Spring Cloud applications, supporting tracing using Zipkin, HTrace, and log-based (e.g. ELK).

  • Spring Cloud Stream's
    lightweight event-driven microservice framework can use a simple declarative model to send and receive messages, mainly implemented as Apache Kafka and RabbitMQ.

  • Spring Cloud Task
    is a microservice framework for quickly building short-lived, limited data processing tasks for adding functional and non-functional features to applications.

  • Spring Cloud Zookeeper
    is based on the service governance component of Apache Zookeeper.

  • The Spring Cloud Gateway
    API gateway component provides routing and filtering functions for requests.

  • Spring Cloud OpenFeign
    is based on Ribbon and Hystrix's declarative service call components, which can dynamically create Spring MVC annotation-based interface implementations for service calls. It has replaced Feign as a first-class citizen in Spring Cloud 2.0.

5. The relationship between microservice calls is complex, how to monitor and troubleshoot?

There is a set of tools for microservice monitoring in the enterprise, called APM. For example: SpringCloudSeluth+Zipkin, Pinpoint, Skywalking, which can realize performance monitoring, link tracking (accurate to a certain code, a certain sql), CPU operation status, and link operation time-consuming.

Of course, you can also use a distributed log management system. Collect the logs of project operation, form statistical reports, and put them into elasticsearch for easy search and viewing. For example: ELK technology stack, GrayLog

6. What is the function of Hystix?

Hystix is ​​a delay and fault-tolerant library open sourced by Netflix, which is used to isolate access to remote services and third-party libraries to prevent cascading failures. The more commonly used methods are thread isolation and service fusing.

Guess you like

Origin blog.csdn.net/qq_36256590/article/details/132166451