preface

Dubbo’s interview questions are summarized in a document to share with you:

The overall architecture

1. The Provider starts and registers the service with the registry

Comsumer starts and connects to the registry and listens for service node changes (asynchronously)

Comsumer sends the call, RPC sends it to the Provider node, and records it to the monitor

Performance optimization

The optimization points are: thread pools (thread pool size, thread async), connections (connection pool size, long connections, short connections), using a high-performance serialization framework, and so on.

A request (page, other business request) comes in.

The consumer

After passing the Active limit, obtain the Maximum number of concurrent dubbo connections (100 at most), obtain the Provider service address, and make RPC calls.

The producer side

The data is deserialized after accepting the maximum connection number limit and being allocated an IO thread callback. Through the business thread pool, business threads are allocated to perform specific tasks.

How many threads can a request have?

Usually two, three at most. IO thread, service thread, asynchronous waiting result feature threadCopy the code

Consumer configuration

2.0.5 Or later

dubbo:reference

The corresponding configuration class: org. Apache. Dubbo. Config. ReferenceConfig

Actives current-limiting

Maximum number of concurrent calls per service consumer per service per method

connections

The default 100

Short connection protocols such as RMI, HTTP, and Hessian limit the maximum number of connections per provider.

Dubbo isometric connection association indicates the number of established long connections

dubbo:consumer

The configuration class: org. Apache. Dubbo. Config. ConsumerConfig.

This tag is the default value of the Dubbo: Reference tag.

Service provider configuration

dubbo:provider

The corresponding configuration class: org. Apache. Dubbo. Config. ReferenceConfig

Accepts current-limiting

Maximum number of connections acceptable to the service provider

iothreads

The default CPU is + 1

IO thread pool, receiving network read/write interrupts, and serialization and deserialization.

The service thread pool does not process services. For details, see Threads configuration. This thread pool is CPU related and is not recommended

Threadpool service threadpool

Default value: fixed

Fixed /cached/limit(above 2.5.3)/eager(above 2.6.x)

executes

The maximum number of requests that a service provider can execute in parallel per service per method

dubbo:provider

The corresponding configuration class: org. Apache. Dubbo. Config. ProviderConfig. This label is the default setting for dubbo:service and Dubbo :protocol labels.

Dubbo cache file

When the JCC service is unavailable, the service address list is obtained from the cache file

Dubbo. Registries. Shanghai. Address = zookeeper: / / 192.168.216.128:2181 dubbo. Registries. Shanghai. A timeout = 10000 Dubbo. Registries. Shanghai. Zone = Shanghai dubbo. Registries. Shanghai. Weight = 100 # address cache files dubbo.registries.shanghai.file=${user.home}/dubbo_shanghai.cacheCopy the code

Cache file contents

#Dubbo Registry Cache #Sun Mar 14 22:44:02 CST 2021 Com. Gupaoedu. Springboot. Dubbo. Provider. Services. IDemoService = empty \ : / / 192.168.217.1 / org. Apache. Dubbo. RPC. Service. The Generic Service? Application \ = spring - the boot - dubbo - sample - consumer&category \ = routers&check \ = false&dubbo \ = 2.0.2 & generic \ = true&init \ = false&int Erface \ = com gupaoedu. Springboot. Dubbo. Provider. Services. IDemoService&pid \ = 16788 & qos enable \ = false&release \ = 2.7.7 & side \ = c Onsumer&sticky \ = false&timestamp empty \ \ = 1615732799082: / / 192.168.217.1 / org. Apache. The dubbo. RPC. Service. GenericService? Application \ = spring - the boot - dubbo - sample - consumer&category \ = configurators&check \ = false&dubbo \ = 2.0.2 & generic \ = true&init \ = fal Se&interface \ = com gupaoedu. Springboot. Dubbo. Provider. Services. IDemoService&pid \ = 16788 & qos enable \ = false&release \ = 2.7.7 & s ide\=consumer&sticky\=false&timestamp\=1615732799082 Dubbo \ : / / 192.168.137.1 \ : 20881 / com. Gupaoedu. Springboot. Dubbo. Provider. Services. IDemoService? Anyhost \ = true&application \ = spring - the boot - dubbo - sample - provider&deprecated \ = false&dubbo \ = 2.0.2 & dynamic \ = true&generic \ = false & interface \ = com gupaoedu. Springboot. Dubbo. Provider. Services. IDemoService&methods \ = getTxt&pid \ = 14552 & release \ = 2.7.7 & seria lization\=kryo&side\=provider&timestamp\=1615708321400 Com. Gupaoedu. Springboot. Dubbo. ISayHelloService = empty \ : / / 192.168.217.1 / com gupaoedu. Springboot. Dubbo. ISayHelloService? Application \ = spring - the boot - dubbo - sample - consumer&category \ = routers&check \ = false&cluster \ = failfast&dubbo \ = 2.0.2 & init \ = false &interface\=com.gupaoedu.springboot.dubbo.ISayHelloService&loadbalance\=consistenthash&methods\=sayHello&mock\=com.gupao Edu. Springboot. Dubbo. Consumer. MockSayHelloService&pid \ = 16788 & protocol \ = dubbo&qos enable \ = false&release \ = 2.7.7 & retries \ = 5 &side\=consumer&sticky\=false&timeout\=5000&timestamp\=1615732841249 The empty \ : / / 192.168.217.1 / com. Gupaoedu. Springboot. Dubbo. ISayHelloService? Application \ = spring - the boot - dubbo - sample - consumer&category \ = configurators&check \ = false&cluster \ = failfast&dubbo \ = 2.0.2 & init \ =false&interface\=com.gupaoedu.springboot.dubbo.ISayHelloService&loadbalance\=consistenthash&methods\=sayHello&mock\=com . Gupaoedu. Springboot. Dubbo. Consumer. MockSayHelloService&pid \ = 16788 & protocol \ = dubbo&qos enable \ = false&release \ = 2.7.7 & retr ies\=5&side\=consumer&sticky\=false&timeout\=5000&timestamp\=1615732841249 Dubbo \ : / / 192.168.137.1 \ : 20881 / com. Gupaoedu. Springboot. Dubbo. ISayHelloService? Anyhost \ = true&application \ = spring - the boot - dubbo - sample - provider&cluster \ = failover&deprecated \ = false&dubbo \ = 2.0.2 & dynamic \ = t Rue&generic \ = false&interface \ = com. Gupaoedu. Springboot. Dubbo. ISayHelloService&methods \ = sayHello&pid \ = 14552 & release \ = 2.7.7 &serialization\=kryo&side\=provider&timestamp\=1615708325667 Com. Gupaoedu. Springboot. Dubbo. Springbootdubbosampleprovider. Services. IDemoService = empty \ : / / 192.168.217.1 / org. Apache. Dubb o.rpc.service.GenericService? Application \ = spring - the boot - dubbo - sample - consumer&category \ = routers&check \ = false&dubbo \ = 2.0.2 & generic \ = true&init \ = false&int erface\=com.gupaoedu.springboot.dubbo.springbootdubbosampleprovider.services.IDemoService&pid\=19440&qos.enable\=false&r Elease \ = 2.7.7 & side \ = consumer&sticky \ = false&timestamp \ = 1615504581825 The empty \ : / / 192.168.217.1 / org. Apache. Dubbo. RPC. Service. GenericService? Application \ = spring - the boot - dubbo - sample - consumer&category \ = configurators&check \ = false&dubbo \ = 2.0.2 & generic \ = true&init \ = fal se&interface\=com.gupaoedu.springboot.dubbo.springbootdubbosampleprovider.services.IDemoService&pid\=19440&qos.enable\=f Alse&release \ = 2.7.7 & side \ = consumer&sticky \ = false&timestamp \ = 1615504581825 The empty \ : / / 192.168.217.1 / org. Apache. Dubbo. RPC. Service. GenericService? Application \ = spring - the boot - dubbo - sample - consumer&category \ = providers&check \ = false&dubbo \ = 2.0.2 & generic \ = true&init \ = false&i nterface\=com.gupaoedu.springboot.dubbo.springbootdubbosampleprovider.services.IDemoService&pid\=19440&qos.enable\=false & release \ = 2.7.7 & side \ = consumer&sticky \ = false&timestamp \ = 1615504581825

Dubbo Admin console

Configure the connection registry address

Dubbo – admin – 0.2.0 \ dubbo – admin – server \ SRC \ main \ resources \ application perproties

Admin. Registry. Address = zookeeper: / / 192.168.137.102:2181 admin. Config - center = zookeeper: / / 192.168.137.102:2181 Admin. Metadata - report. Address = zookeeper: / / 192.168.137.102:2181Copy the code

run

Dubo-admin-0.2.0 > mvn-projects dubo-admin-server spring-boot:runCopy the code

Metadata center

The metadata node manages the configuration information on the original URL

Service publishing process

Dubbo.apache.org/zh/docs/v2….

Each layer specification

config

Load configuration to provide unified external configuration classes

proxy

Service broker layer

registry

Registry layer

cluster

Routing layer, including load balancing and fault tolerance

monitor

Monitoring layer, RPC call times and call time monitoring

protocol

The Remote Invocation layer (which encapsulates RPC calls) has Protocol, Invoker, and half interfaces based on Invocation and Result

exchange

Information exchange layer, which encapsulates the Request and Response mode, and uses Request and Response as the center. The expansion interface is Exchanger, ExchangeChannel, ExchangeClient and ExchangeServer

transport

The network transport layer abstracts MINA and Netty as the unified interface, takes Message as the center, and extends the interfaces as Channel, Transporter, Client, Server, and Codec

serialize

Serialization, ObjectInput, ObjectOutput, ThreadPool

The module of the subcontract

Dubo-config Configuration module

Dubbo is the external API of Dubbo. Users use Dubbo through Config to hide all details of Dubbo.

Dubbo-rpc remote call module

Abstract various protocols, as well as dynamic proxies, involving only one-to-one calls, with no concern for cluster management.

Dubo-registry registry module

Clustering based on registries delivering addresses, and abstractions to various registries

Dubo-cluster Cluster module

Masquerade multiple service providers as one provider, including load balancing, fault tolerance, routing, etc. The cluster address list can be statically configured or delivered by the registry.

Dubo-monitor Monitoring module

Count the number of service calls, call time, and call chain tracking services.

The monitored data can be reported to the service address of the connected monitoring center.

Dubo-filter Indicates the filter module

Dubo-auth filter module

Auth and qos

qos

Online o&M: You can run commands to access the Dubbo service

Qos-port =8888 dubo.application. Qos-accept-foreign-ip =false dubo.application. Qos-enable =trueCopy the code

Dubo-remoting remote communication module

Equivalent to an implementation of the Dubbo protocol, this package is not required if RPC uses the RMI protocol.

Dubo-common public logic module

Includes Util classes and generic models.

Dubo-container Indicates the container module

The Main. The Main dubbo (args) started

Load the Spring configuration or annotations

Then start a Netty Server based on the configured information

Dubbo invocation chain

The light green part is the service provider;

The light blue is the service consumer;

The dark green parts are all extension points;

The domain model

In Dubbo’s core domain model:

Protocol

Is the service domain, which is the main functional entry for Invoker exposure and references and is responsible for the lifecycle management of Invoker.

Invoker

The entity domain is the core model of Dubbo to which other models rely or transform. It represents an executable to which invoke calls can be made. It may be a local implementation, a remote implementation, or a cluster implementation.

Invocation

The session domain holds variables during the call, such as method names, parameters, and so on.

Service consumption process

SPI extension point

The last

I have arranged a Dubbo related interview materials, Java systematic materials (including Java core knowledge points, interview topics and the latest Internet real questions in 20 years, e-books, etc.) friends who need to pay attention to the public number can be obtained.