1. Introduction

Dubbo is a high-performance, lightweight, open source Java RPC framework that provides three core capabilities: interface-oriented remote method invocation, intelligent fault tolerance and load balancing, and automatic service registration and discovery.

  • Remote Procedure Call (RPC). Simply understood, a node requests services provided by another node

www.jianshu.com/p/7d6853140…

Main core component

  • Remoting: A network communication framework that implements sync-over-async and Request-Response message mechanisms
  • RPC: A remote procedure call abstraction that supports load balancing, disaster recovery, and clustering
  • Registry: The service catalog framework is used for registering services and publishing and subscribing to service events

The official website link: dubbo.apache.org/zh/

Is alibaba company open source a high-performance excellent service framework!!

Introductory teaching:

Segmentfault.com/a/119000001…

The following content from dubbo.apache.org/zh/docs/v2….

Background 2.

With the development of the Internet, the scale of website applications keeps expanding, and the conventional vertical application architecture can no longer cope with it. The distributed service architecture and mobile computing architecture are imperative, and a governance system is urgently needed to ensure the orderly evolution of the architecture.

Single application Architecture

When site traffic is low, only one application is needed to deploy all functions together to reduce deployment nodes and costs. At this point, data access frameworks (ORM) that simplify the work of adding, deleting, modifying and reviewing are key.

Vertical application Architecture

As traffic increases, the acceleration caused by a single application increases less and less. One way to improve efficiency is to break the application into several unrelated applications to improve efficiency. At this point, a Web framework (MVC) for accelerating front-end page development is key.

Distributed Service Architecture

With the increasing number of vertical applications, the interaction between applications is inevitable. Core businesses are extracted as independent services, gradually forming a stable service center, so that front-end applications can respond to changing market demands more quickly. At this point, the distributed Services framework (RPC) for business reuse and integration is key.

Mobile Computing Architecture

As the number of services increases, problems such as capacity evaluation and waste of small service resources gradually emerge. In this case, a scheduling center needs to be added to manage cluster capacity in real time based on access pressure to improve cluster utilization. At this point, a resource scheduling and Governance center (SOA) for improving machine utilization is key.

3. The demand

Before large-scale servitization, applications might simply expose and reference remote services through tools such as RMI or Hessian, invoke services by configuring service URLS, and load balance through hardware such as F5.

As there are more and more services, service URL configuration management becomes very difficult and the single point of pressure on the F5 hardware load balancer increases. A service registry is needed to dynamically register and discover services and make their location transparent. In addition, by obtaining the address list of the service provider from the consumer, the software load balancing and Failover can be implemented to reduce the dependence on the F5 hardware load balancer and reduce part of the cost.

As the dependencies between services become so complex that it is not even clear which application should be launched before which, the architect cannot fully describe the application’s architectural relationships. In this case, dependency diagrams between applications need to be drawn automatically to help the architect clarify the relationships.

Then, as more and more services are invoked, the capacity of the service is exposed. How much machine support does the service require? When should you add machines? In order to solve these problems, the first step is to calculate the service’s current daily call usage and response time as a reference index for capacity planning. Secondly, it is necessary to adjust the weight dynamically. On the line, the weight of a machine has been increased, and the change of response time is recorded in the process of increasing, until the response time reaches the threshold value, the page view is recorded at this time, and then the total capacity is reversed by the page view multiplied by the number of machines.

These are the basic requirements of Dubbo.

4. Architecture

Node Role description
node The role that
Provider The service provider that exposes the service
Consumer Service consumer that invokes the remote service
Registry A registry for service registration and discovery
Monitor A monitoring center that collects statistics on service invocation times and invocation time
Container Service run container
Call Relationship Description
  1. The service container is responsible for starting, loading, and running the service provider.
  2. At startup, service providers register their services with the registry.
  3. At startup, service consumers subscribe to the registry for the services they need.
  4. The registry returns a list of service provider addresses to the consumer, and if there are changes, the registry pushes the change data to the consumer based on the long connection.
  5. The service consumer, from the provider address list, selects one provider to call based on the soft load balancing algorithm. If the call fails, selects another one to call.
  6. Service consumers and providers accumulate calls and call times in memory and regularly send statistics to the monitoring center every minute.

The Dubbo architecture is characterized by connectivity, robustness, scalability, and scalability to future architectures.

5. Usage

Remote service Spring configuration

On the basis of the local service, only a simple configuration is required to complete the remote:

  • The abovelocal.xmlThe configuration is split in two, placing the service definition part on the service providerremote-provider.xml, place the service reference part at the service consumerremote-consumer.xml.
  • And add exposed service configurations on the provider side<dubbo:service>To add a reference service configuration at the consumer<dubbo:reference>.

remote-provider.xml:

<! Implement remote services as local services -->
<bean id="XxxService" class="Com. XXX. XxxServiceImpl" /> 
<! -- Add exposed remote service configuration -->
<dubbo:service interface="Com. XXX. XxxService" ref="XxxService" /> 
Copy the code

remote-consumer.xml:

<! -- Add a reference to remote service configuration -->
<dubbo:reference id="XxxService" interface="Com. XXX. XxxService" />
<! Use remote services as local services -->
<bean id="XxxAction" class="Com. XXX. XxxAction"> 
    <property name="XxxService" ref="XxxService" />
</bean>
Copy the code

Dubbo uses a full Spring configuration mode to transparently access applications without any API intrusion. You only need to load Dubbo’s configuration with Spring. Dubbo is loaded based on Spring’s Schema extension.

If you don’t want to use Spring configuration, you can call it through the API.

Administrative Console Installation

The current version of the management console is under development, which has completed the functions of service query and service governance, and adopts the mode of separating the front and back ends. The specific installation and use steps are as follows:

Installation:

git clone https://github.com/apache/dubbo-admin.git /var/tmp/dubbo-admin
cd /var/tmp/dubbo-admin
mvn clean package
Copy the code

Configuration 1:

Configuration file is: dubbo - admin - backend/SRC/main/resources/application. The main configuration properties are: Dubbo. Registry. Address = zookeeper: / / 127.0.0.1:2181Copy the code

Activation:

mvn --projects dubbo-admin-server spring-boot:run
Copy the code

For other configurations, visit github documentation:

https://github.com/apache/dubbo-admin
Copy the code

Access:

http://127.0.0.1:8080
Copy the code

Install ZooKeeper as the registry

www.cnblogs.com/cuihongyu35…

Start zkServer: Go to the bin directory and double-click zkserver. CMD to start zkClient: go to the bin directory and double-click zkcli. CMD to start zkClient

The final result

The default user name and password are root

test

Port =8081 dubo.application. name=provider-server # # dubbo registry address. Registry. Address = zookeeper: / / 127.0.0.1:2181 dubbo. Registry. Address = zookeeper: / / 127.0.0.1:2181 # element according to address Dubbo. Metadata - report. Address = zookeeper: / / 127.0.0.1:2181 # 2.7 to support the allocation center writing below, This way is to use 2.6 # dubbo. Config - center. Address = zookeeper: / / 127.0.0.1:2181 # scanning under the specified package service dubbo. Scan. The base - packages = com. Gip. ServiceCopy the code

Port =8082 # Dubo.application. Name =consumer-server # address dubbo registry. The registry. Address = zookeeper: / / 127.0.0.1:2181Copy the code