Dubbo Source Analysis Series three--Architecture principle

Source: Internet
Author: User
Tags dashed line

1 Core functions

The first step is to understand the three core features that Dubbo provides:

    • Remoting: Remote Communication
      • Provides an abstract encapsulation of multiple NIO frameworks, including "synchronous-to-asynchronous" and "request-response" modes of information exchange.
    • Cluster: Service Framework
      • Provides transparent remote procedure calls based on interface methods, including multi-protocol support, and cluster support such as soft load balancing, failure tolerance, address routing, and dynamic configuration.
    • Registry: Service Registration Center
      • Based on the Registry directory service, the service consumer can dynamically find the service provider, make the address transparent, and enable the service provider to increase or decrease the machine smoothly.
2 Dubbo relationship structure between various components 2.1 call relationship

Node role description
node Role Description
Provider Service providers for exposing services
Consumer Invoking a service consumer of a remote service
Registry Registration Center for service Registration and discovery
Monitor Monitoring Center for the number of calls and call times of the statistics service
Container Service Run Container
2.2 Dependencies

Legend Description:

    • Figure Small Square Protocol, Cluster, Proxy, Service, Container, Registry, Monitor representative layer or module, blue expression and business have interaction, green means only to Dubbo internal interaction.
    • The background squares Consumer, Provider, Registry, and Monitor represent the deployment of logical topology nodes.
    • The blue dashed line in the diagram is called at initialization time, red dashed lines are run-time asynchronous calls, and red solid lines are called for runtime synchronization.
    • The figure contains only the layers of the RPC, not the layers of the Remoting, Remoting the whole is implied in Protocol.
Call Chain

Expand the red call chain for the master plan, as follows:

Exposure Service Timing

Expand the blue initialization chain of the service provider exposure service on the left side of the overall design diagram, which is as follows:

Referencing service Timings

Expand the blue initialization chain for the service consumer reference service on the right side of the general design chart, which is as follows:

Horizontal hierarchy of 3 Dubbo

The most important feature of the Dubbo is that it is structured in a hierarchical manner , which allows for decoupling (or maximum coupling) between the layers. So, we look at the architecture of Dubbo horizontally in a hierarchical way

Overall design

Legend Description:

    • The interface used by the service consumer is the light-blue background on the left, and the interface used by the service provider on the right green background is on the middle axis for both sides.
    • The figure from bottom to top is divided into 10 layers, each layer is one-way dependency, the black arrow on the right represents the dependency between the layers, each layer can be stripped of the upper layer is reused, wherein the Service and Config layer is the API, the other layers are SPI.
    • The green small block is the extension interface, the blue Small block is the implementation class, the diagram shows only the implementation class for associating each layer.
    • The blue dashed line is the initialization process, that is, the assembly chain at startup, the red solid is the method call process, that is, run Si cho, purple triangle arrow is inherited, you can treat the class as the same node of the parent class, the text on the line is called method.
Description of each layer
  • Config layer : External configuration Interface, in ServiceConfig , ReferenceConfig as the center, you can initialize the configuration class directly, or you can generate the configuration class through the spring parsing configuration
  • Proxy Service agent Layer : Service interface transparent proxy, generate service client Stub and server side Skeleton, to ServiceProxy Center, extend interface asProxyFactory
  • Registry Registration Center Layer : The registration and discovery of the package service address, the service URL is the center, the expansion interface is RegistryFactory , RegistryRegistryService
  • Cluster Routing layer : Encapsulates Routing and load balancing for multiple providers, and bridges the registry to the Invoker center, extending the interface for,, Cluster Directory Router ,LoadBalance
  • Monitor monitoring Layer : The number of RPC calls and call time monitoring, to the Statistics Center, the expansion interface for MonitorFactory , MonitorMonitorService
  • protocol Remote Call Layer : Encapsulates RPC calls, to Invocation , Result Center, extend interface for Protocol , Invoker ,Exporter
  • Exchange information exchange layer : Encapsulate request response mode, synchronous to asynchronous, to Request , Response Center, extend interface for Exchanger ,, ExchangeChannel ExchangeClient ,ExchangeServer
  • Transport network Transport layer : abstract Mina and Netty for the unified interface to the Message Center, the expansion interface for,,, Channel Transporter Client Server ,Codec
  • Serialize Data serialization layer : Reusable tools that extend the interface to,,, Serialization ObjectInput ObjectOutputThreadPool
Relationship Description
    • in RPC, Protocol is the core layer, which means that a non-transparent RPC call can be done with Protocol + Invoker + exporter, and then Filter The intercept point on the main process of the Invoker. The Consumer and Provider in the
    • diagram are abstract concepts, just to make it more intuitive for a person to see which classes belong to the client and server side, without client and server because Dubbo uses Provider in many scenarios, Con Sumer, Registry, Monitor divides the logical Tuopu node and maintains a unified concept.
    • While Cluster is a peripheral concept, the goal of Cluster is to disguise multiple Invoker as a Invoker so that others focus on Protocol layer Invoker, plus Cluster or remove cluste R does not affect other layers, because there is no need to Cluster when there is only one provider. The
    • proxy layer encapsulates all the interfaces of the transparent agent, and in the other layers are Invoker-centric, only to expose to the user, only use Proxy to turn Invoker into an interface, or the interface implementation into Invoker, that is, remove the Proxy layer RP C can Run, but not so transparent, it does not look like local services to tune the remote service.
    • and the Remoting implementation is the implementation of the Dubbo protocol, if you choose the RMI protocol, the entire Remoting will not be used, Remoting internally again zoned Transport Transport layer and exchange information exchange layer, Transpor The T layer is only responsible for one-way message transmission, is an abstraction of Mina, Netty, Grizzly, it can also extend the UDP transport, and the Exchange layer encapsulates the request-response semantics on top of the transport layer. The
    • Registry and Monitor are not really a layer, but rather a separate node, just for a global overview, to draw together in layers.

Reference articles






Dubbo Source Analysis Series three--Architecture principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.