Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the latest Dubbo interview questions available in 2021

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "what are the latest version of Dubbo interview questions in 2021". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. basic knowledge

1. Why use Dubbo?

With the further development of services, there are more and more services, and the invocation and dependency between services are becoming more and more complex. Service-oriented architecture (SOA) is born, and a series of corresponding technologies are derived, such as service framework that encapsulates service provision, service invocation, connection processing, communication protocol, serialization, service discovery, service routing, log output and so on. Thus a service governance framework for distributed systems emerged, and so did Dubbo.

2. What is Dubbo?

Dubbo is a high-performance, lightweight open source RPC framework, which provides efficient service governance solutions such as automatic service registration and automatic discovery, and can be seamlessly integrated with the Spring framework.

3. What are the usage scenarios of Dubbo?

Transparent remote method invocation: call remote methods as if they were local methods, with simple configuration and no API intrusion.

Soft load balancing and fault tolerance mechanism: hardware load balancers such as F5 can be replaced in the intranet to reduce costs and reduce a single point.

Automatic service registration and discovery: no longer need to write dead service provider address, the registry queries the service provider's IP address based on the interface name, and can smoothly add or delete service providers.

4. What are the core functions of Dubbo?

Remoting: network communication framework that provides abstract encapsulation of a variety of NIO frameworks, including "synchronous to asynchronous" and "request-response" modes of information exchange. Cluster: service framework that provides transparent remote procedure calls based on interface methods, including multi-protocol support, as well as soft load balancing, failure tolerance, address routing, dynamic configuration and other cluster support.

Registry: service registration, based on the registry directory service, enables the service consumer to dynamically find the service provider, makes the address transparent, and enables the service provider to smoothly add or decrease machines.

5. What are the core components of Dubbo?

Provider: the provider of the exposed service

Consumer: invoking the remote service consumer

Registry: service Registration and Discovery Registry

Monitor: monitoring center and access call statistics

Container: service running container

6. Dubbo server registration and discovery process?

The service container Container is responsible for starting, loading, and running the service provider.

Upon startup, the service provider Provider registers the services it provides with the registry.

When the service consumer Consumer starts, it subscribes to the registry for the services it needs.

The registry Registry returns a list of service provider addresses to the consumer, and if there is a change, the registry will push the change data to the consumer based on the persistent connection.

Service consumer Consumer, from the provider address list, selects one provider to call based on the soft load balancing algorithm, and then chooses another one if the call fails.

Service consumer Consumer and provider Provider accumulate the number of calls and call time in memory, and regularly send statistics to the monitoring center Monitor every minute.

2. Architecture design 7. What are the layers in the overall architecture design of Dubbo?

Interface service layer (Service): this layer is related to business logic, and the corresponding interfaces and implementations are designed according to the business of provider and consumer.

Configuration layer (Confifig): configure interfaces externally, centered on ServiceConfifig and ReferenceConfifig

Service proxy layer (Proxy): the transparent proxy of the service interface, which generates the client Stub of the service and the Skeleton of the server to

ServiceProxy is the center, and the extension interface is ProxyFactory

Service Registration layer (Registry): encapsulates the registration and discovery of service addresses, with the service URL as the center and the extended interface as

RegistryFactory 、 Registry 、 RegistryService

Routing layer (Cluster): encapsulates the routing and load balancing of multiple providers, and bridges the registry with Invoker as the center, and the extended interfaces are Cluster, Directory, Router and LoadBlancce

Monitoring layer (Monitor): monitoring the number and time of RPC calls, with Statistics as the center, and extending interfaces for MonitorFactory, Monitor and MonitorService

Remote invocation layer (Protocal): encapsulates RPC calls, centers on Invocation and Result, and extends interfaces for Protocal, Invoker and Exporter

Information exchange layer (Exchange): encapsulates the request response mode and changes steps synchronously. Centered on Request and Response

The extended interfaces are Exchanger, ExchangeChannel, ExchangeClient and ExchangeServer

Network Transport layer (Transport): abstract mina and netty are unified interfaces, with Message as the center, and extended interfaces are Channel, Transporter, Client, Server and Codec

Data serialization layer (Serialize): reusable tools with extension interfaces for Serialization, ObjectInput, ObjectOutput, and ThreadPool

8. Dubbo Monitor implementation principle?

The Consumer side takes the fifilter chain before initiating the call; when the provider side receives the request, it also walks through the fifilter chain before the real business logic processing. By default, Monitorfifilter is found in the fifilter chain of both consumer and provider.

MonitorFilter sends data to DubboMonitor

DubboMonitor temporarily stores the data to ConcurrentMap statisticsMap after aggregating the data (the statistics in the default aggregate 1min), and then uses a thread pool with three threads (thread name: DubboMonitorSendTimer) to call SimpleMonitorService to traverse the statistics in the statisticsMap every 1min clock. Every time one is sent, the AtomicReference of the current Statistics is reset

SimpleMonitorService crammed this aggregated data into the BlockingQueue queue (queue capitalization is 100000)

SimpleMonitorService uses a background thread (thread name: DubboMonitorAsyncWriteLogThread) to write data from queue to a file (this thread writes in an endless loop)

SimpleMonitorService also uses a thread pool with 1 thread (thread name: DubboMonitorTimer) to chart the statistics in the file every 5min clock.

3. Distributed framework 9. What are the similar distributed frameworks of Dubbo?

The more famous one is Spring Cloud.

10. What is the relationship between Dubbo and Spring Cloud?

Dubbo is the product of the SOA era, which focuses on service invocation, traffic distribution, traffic monitoring and circuit breakers. Spring Cloud was born in the era of micro-service architecture, considering all aspects of micro-service governance.

Based on the advantages of Spring and Spring Boot, the two frameworks have different goals at the beginning. Dubbo positioning service governance and Spring Cloud is to create an ecology.

12. What's the difference between Dubbo and Dubbox?

Dubbox is an extension project based on Dubbo after Dubbo stops maintenance, such as adding services that can be called by Restful, updating open source components, etc.

Registration centres 13. What are the registration centers of Dubbo?

Multicast registry: Multicast registry does not need any central node, as long as the broadcast address, it can register and discover the service, which is based on the multicast transmission in the network.

Zookeeper registry: based on the distributed coordination system Zookeeper implementation, using Zookeeper's watch mechanism to achieve data change.

Redis registry: based on Redis implementation, using key/map storage, key storage service name and type, key storage service url,value service expiration time in map. Redis-based publish / subscribe mode notifies data changes.

Simple registry.

It is recommended to use Zookeeper as the registry

14. Dubbo's registry cluster is down. Can publishers and subscribers still communicate with each other?

You can communicate. When starting Dubbo, consumers will pull data such as the address interface of the registered producer from Zookeeper and cache it locally. Each call is made according to the locally stored address.

5. Cluster 15. What load balancing strategies does Dubbo cluster provide?

Random LoadBalance: randomly select the provider strategy, which is conducive to dynamically adjust the provider weight. The higher the cross-section collision rate is, the more times it is called, the more uniform the distribution is.

RoundRobin LoadBalance: round-robin selection provider strategy, evenly distributed, but there is a problem of request accumulation.

LeastActive LoadBalance: the least active invocation strategy solves the problem that slow providers receive fewer requests.

ConstantHash LoadBalance: consistent Hash policy, so that requests for the same parameters are always sent to the same provider, and a machine goes down, which can be allocated to other providers based on virtual nodes, so as to avoid drastic changes in providers.

16. What are the cluster fault tolerance solutions of Dubbo?

Failover Cluster: auto switch when failure occurs. If failure occurs, retry other servers. It is usually used for read operations, but retry results in a longer delay.

Failfast Cluster: quick failure, only one call is made, and an error is reported immediately after the failure. It is usually used for non-idempotent write operations, such as adding records.

Failsafe Cluster: failed security. If an exception occurs, ignore it directly. It is commonly used for operations such as writing audit logs.

Failback Cluster: automatic recovery of failed requests. Failed requests are recorded at the background and resent regularly. It is commonly used for message notification operations.

Forking Cluster: multiple servers are called in parallel, and as long as one is successful, it is returned. It is usually used for read operations with high real-time requirements, but it needs to waste more service resources. The maximum number of parallelism can be set through forks= "2".

Broadcast Cluster: broadcasts call all providers, one by one. If any station reports an error, it reports an error. It is typically used to notify all providers to update local resource information such as caches or logs.

Configuration 17. How is the Dubbo configuration file loaded into Spring?

When the Spring container starts, it will read some default schema of Spring and custom schema of Dubbo. Each schema will correspond to its own NamespaceHandler,NamespaceHandler to parse the configuration information through BeanDefifinitionParser and convert it into a bean object that needs to be loaded!

18. What are the core configurations?

19. What are the ways to set Dubbo timeout?

There are two ways to set Dubbo timeout:

The service provider sets the timeout. In the user documentation of Dubbo, it is recommended to configure as much as possible if you can configure more on the server, because the service provider is more aware of the service features it provides than the consumer.

The service consumer sets the timeout. If the timeout is set on the consumer side, it is mainly on the consumer side, that is, the priority is higher. Because the service caller is more flexible in setting timeout control. If the consumer times out, the server thread will not be customized and a warning will be generated.

20. What happens when the service invocation times out?

When the dubbo invokes the service unsuccessfully, the default is to retry twice.

Communication protocol 21. What communication framework does Dubbo use?

Netty is used as the communication framework by default.

twenty-two。 What protocols does Dubbo support and what are their advantages and disadvantages?

Dubbo: single persistent connection and NIO asynchronous communication are suitable for service calls with large concurrency and small amount of data, and consumers are much larger than providers. Transport protocol TCP, asynchronous Hessian serialization. Dubbo recommends using the dubbo protocol.

RMI: implemented by RMI protocol of JDK standard, Serializable interface is required for transmission parameters and return parameter objects, Java standard serialization mechanism is used, blocking short connection is used, transmission packet size is mixed, the number of consumers and providers is about the same, files can be transferred, and transfer protocol TCP. Multiple short connection TCP protocol transmission, synchronous transmission, suitable for conventional remote service invocation and RMI interoperation. A security vulnerability exists in Java serialization when relying on an earlier version of the Common-Collections package.

WebService: a WebService-based remote call protocol that integrates CXF implementation and provides interoperability with native WebService. Multiple short connections, based on HTTP transmission, synchronous transmission, suitable for system integration and cross-language calls.

HTTP: a remote invocation protocol based on Http form submission, implemented using Spring's HttpInvoke. Multiple short connections, transport protocol HTTP, mixed input parameters, more providers than consumers, need to call JS to applications and browsers.

Hessian: integrated Hessian services, based on HTTP communication, using Servlet exposure services, Dubbo embedded Jetty as the server when the default implementation, providing interoperability with Hession services. Multiple short connections, synchronous HTTP transmission, Hessian serialization, larger input parameters, larger providers than consumers, greater pressure on providers, and transferable files.

Memcache: RPC protocol implemented based on Memcache.

Redis: RPC Protocol based on Redis

8. Design pattern 23. What design patterns are used in Dubbo?

The Dubbo framework uses a variety of design patterns in the initialization and communication process, which can flexibly control the functions such as class loading, permission control and so on.

Operation and maintenance management 24. How is the service online compatible with the old version?

You can transition with a version number (version). Multiple different versions of services are registered with the registry, and services with different version numbers do not refer to each other. This is a bit similar to the concept of service grouping.

25. What can the Dubbo telnet command do?

After the dubbo service is released, we can use the telnet command for debugging and management. The port provided by Dubbo2.0.5 and above supports telnet command.

twenty-six。 Does Dubbo support service downgrade?

To set the mock= "return null" through dubbo:reference. The value of mock can also be changed to true, and then implement a Mock class in the same path as the interface. The naming rule is the suffix "interface name + Mock". Then implement your own downgrade logic in the Mock class

twenty-seven。 How does Dubbo stop gracefully?

Dubbo does graceful downtime through JDK's ShutdownHook, so if you use a forced shutdown instruction such as kill-9 PID, graceful downtime will not be performed, only through kill PID.

SPI28. The difference between Dubbo SPI and Java SPI?

JDK SPI:

The SPI of the JDK standard loads all extension implementations at once, and if some extensions are time-consuming but not used, it is a waste of resources. So it's not realistic to just want to load some implementation.

DUBBO SPI:

1. Extend Dubbo without changing the source code of Dubbo

2. Delay loading, you can load only the extension implementation you want to load at a time.

3. Add support for extension points IOC and AOP, and one extension point can be directly injected into other extension points by setter.

4. The extension mechanism of Dubbo can well support third-party IoC containers, and Spring Bean is supported by default.

Eleven, others 29. Does Dubbo support distributed transactions?

Currently, it is not supported, but can be implemented through the tcc-transaction framework.

Introduction: tcc-transaction is an open source TCC compensatory distributed transaction framework

TCC-Transaction avoids its own intrusion into the business code through the implicit parameter transfer function of Dubbo.

thirty。 Can Dubbo cache the results?

To improve the speed of data access. Dubbo provides declarative caching to reduce the workload of caching for users.

In fact, there is one more label cache= "true" than an ordinary configuration file.

thirty-one。 What packages does Dubbo have to rely on?

Dubbo must rely on JDK, others are optional.

thirty-two。 What serialization methods does Dubbo support?

Hessian serialization is used by default, and Duddo, FastJson, and Java come with serialization.

thirty-three。 What measures does Dubbo have in terms of security?

Dubbo uses Token tokens to prevent users from bypassing the registry to connect directly, and then manages authorization on the registry.

Dubbo also provides a blacklist and whitelist of services to control the callers allowed by the service.

thirty-four。 Is the service call blocked?

It is blocked by default and can be called asynchronously, and those with no return value can do so. Dubbo is a non-blocking parallel call based on NIO. The client does not need to start multi-thread to call multiple remote services in parallel. The cost of multi-thread is relatively small, and the asynchronous call will return a Future object.

thirty-five。 What is the principle that service providers can achieve failure kickout?

Service failure kicks out the temporary node principle based on zookeeper.

thirty-six。 Can I directly connect to a service when there are multiple registrations for the same service?

You can connect directly to a point-to-point, modify the configuration, or directly use a service through telnet.

thirty-seven。 If the Dubbo service is downgraded, what can I do if I fail and try again?

You can set the mock= "return null" through dubbo:reference. The value of mock can also be changed to true, and then implement a Mock class in the same path as the interface. The naming rule is the suffix "interface name + Mock". Then implement your own downgrade logic in the Mock class

What are the problems encountered in the use of 38.Dubbo?

The corresponding service cannot be found in the registry. Check whether the service implementation class has added the @ service annotation and cannot connect to the registry. Check whether the corresponding test ip in the configuration file is correct.

12. RPC39. Why is there a RPC?

Http interface is a communication means commonly used in the initial stage of solving the isolated island of information under the condition of few interfaces and less interaction between the system and the system. The advantage is simple, direct and convenient to develop. Make use of the ready-made http protocol for transmission. However, if it is a large website with many internal subsystems and many interfaces, the benefits of the RPC framework will be shown, first of all, long links, so that you don't have to shake hands three times like http, which reduces the network overhead; secondly, the RPC framework generally has a registration center and rich monitoring and management. Publishing, offline interface, dynamic extension, etc., are imperceptible and unified operations for callers. The third is security. Finally, there is the recent popularity of service-oriented architecture, service-oriented governance, RPC framework is a strong support.

Socket is only a simple way of network communication, which only creates a communication channel for both sides of the communication. In order to realize the function of rpc, it needs to be encapsulated to achieve more functions.

RPC generally works with netty framework and spring custom annotations to write lightweight frameworks. In fact, socket is encapsulated inside netty, and the IO of newer jdk is generally NIO, that is, non-blocking IO. In highly concurrent websites, the advantage of RPC will be obvious.

forty。 What is RPC?

forty-one。 PRC architecture components

A basic RPC architecture should contain at least the following four components:

1. Client (Client): service caller (service consumer)

2. Client Client Stub: store the server address information, package the client request parameter data information into a network message, and then send it to the server through network transmission.

3. Server Stub: receive the request message sent by the client and unpack it, and then call the local service for processing. 4. Server: the real provider of the service

Specific calling procedure:

1. The service consumer (client client) invokes the service that needs to be consumed by calling the local service

2. After receiving the call request, the client stub (client stub) is responsible for serializing (assembling) the method, input parameters and other information into a message body that can be transmitted over the network.

3. The client stub (client stub) finds the remote service address and sends the message to the server over the network

4. The server stub (server stub) decodes the message after receiving it (deserialization operation)

5. The server stub (server stub) invokes the local service according to the decoding result for related processing

6. The local service executes the specific business logic and returns the processing result to the server stub (server stub)

7. The server stub (server stub) repackages the returned result into a message (serialization) and sends it to the consumer over the network

8. The client client stub receives the message and decodes it (deserialization)

9. Service consumers get the final result

forty-two。 The difference between RPC and SOA, SOAP and REST

1 、 REST

It can be seen that it is a direct application of HTTP protocol, which is based on JSON by default. It is simple to use, low in learning cost, high in efficiency, but low in security.

2 、 SOAP

SOAP is a data exchange protocol specification, is a lightweight, simple, XML-based protocol specification. And SOAP can be seen as a heavyweight protocol, based on XML, SOAP in the security aspect is through the use of XML-Security and XML-Signature two specifications to form WS-Security to achieve security control, has been supported by various manufacturers. What are its advantages? The simple summary is: easy to use, flexible, cross-language, cross-platform.

3 、 SOA

Service-oriented architecture, which can distribute, combine and use loosely coupled coarse-grained application components through the network according to the requirements. The service layer is the foundation of SOA, which can be directly called by the application, so as to effectively control the human dependence of the interaction with the software agent in the system. SOA is a coarse-grained, loosely coupled service architecture, which communicates between services through a simple and precisely defined interface, without involving the underlying program interface and communication model. SOA can be seen as a natural extension of the Bamp S model, XML (a subset of the standard general markup language) / Web Service technology.

4. What's the difference between REST, SOAP and RPC?

There is not much difference. Their essence is to provide basic services that can support distribution. The biggest difference lies in the different application scenarios brought about by their respective characteristics.

forty-three。 What are the problems that need to be solved in the RPC framework?

1. How to determine the communication protocol between the client and the server?

2. How to communicate more efficiently?

3. How are the services provided by the server exposed to the client?

4. How does the client discover these exposed services?

5. How to serialize and deserialize request objects and response results more efficiently?

forty-four。 What is the implementation basis of RPC?

1. Very efficient network communication is required. For example, Netty is generally chosen as the network communication framework.

2. Need to have a more efficient serialization framework, such as Google's Protobuf serialization framework

3. Reliable addressing methods (mainly the discovery of providing services), for example, you can use Zookeeper to register services, etc.

4. If it is a RPC call with session (state), you also need to have the function of session and state persistence.

forty-five。 What key technologies are used by RPC?

1. Dynamic agent

Java dynamic proxy technology is needed to generate Client Stub (client stub) and Server Stub (server stub). You can use the native dynamic proxy mechanism provided by JDK, or you can use open source: CGLib proxy, Javassist bytecode generation technology.

2. Serialization and deserialization

In the network, all data will be converted into bytes for transmission, so in order to enable parameter objects to be transmitted in the network, these parameters need to be serialized and deserialized. Serialization: the process of converting an object into a sequence of bytes is called object serialization, that is, the process of encoding. Deserialization: the process of restoring a sequence of bytes to an object is called deserialization of the object, that is, the process of decoding. Currently, there are more efficient open source serialization frameworks, such as Kryo, FastJson and Protobuf. Deserialization: the process of restoring a sequence of bytes to an object is called deserialization of the object, that is, the process of decoding. Currently, there are more efficient open source serialization frameworks, such as Kryo, FastJson and Protobuf.

3. NIO communication

For the sake of concurrency performance, the traditional blocking IO is obviously not suitable, so we need asynchronous IO, namely NIO. Java provides a solution for NIO, and Java 7 provides better NIO.2 support. You can choose Netty or MINA to solve the problem of NIO data transfer.

4. Service registry

Optional: Redis, Zookeeper, Consul, Etcd. ZooKeeper is generally used to provide service registration and discovery capabilities to solve single point of failure and distributed deployment problems (registry).

forty-six。 What are the mainstream RPC frameworks?

forty-seven。 Implementation principle Architecture Diagram of RPC

That is to say, two servers, A _ Magi B, one application is deployed on server A, and wants to call the functions / methods provided by the application on server B. because it is not in the same memory space, it cannot be called directly, so it needs to express the semantics of the call and convey the data of the call through the network.

For example, server A wants to call a method on server B:

1. Establish communication

First of all, we have to solve the problem of communication: that is, if machine A wants to call machine B, it must first establish a communication connection. Mainly by establishing a TCP connection between the client and the server, all the exchanged data from the remote procedure call is transmitted in this connection. The connection can be an on-demand connection, which is broken at the end of the call, or a long connection, where multiple remote procedure calls share the same connection. Usually, this connection can be an on-demand connection (the connection is established when it needs to be called, and then disconnected immediately after the call ends), or it can be a long-term connection (the client and the server maintain a long-term hold after the connection is established. Regardless of the sending of numerous data packets at this time, you can cooperate with the heartbeat detection mechanism to regularly check whether the established connection is alive and valid), and multiple remote procedure calls share the same connection.

2. Service addressing

To solve the addressing problem, that is, how the application on server A tells the underlying RPC framework, how to connect to server B (such as a host or IP address) and a specific port, and what is the name of the method. Usually we need to provide the B machine (hostname or IP address) and a specific port, and then specify the name of the called method or function and input and output parameters and other information, so that we can complete a call to the service. Reliable addressing (mainly service discovery) is the cornerstone of RPC implementation, such as using Redis or Zookeeper to register services, and so on.

2.1 from the point of view of the service provider:

When the service provider starts, it needs to register the services it provides with the designated registry, so that the service consumers can find it through the service registry; when the service provider stops providing services for various reasons, you need to log out the stopped services from the registry The service provider needs to send heartbeat detection to the service registry periodically. If the service registry does not receive the heartbeat from the service provider for a period of time, it thinks that the service provider has stopped the service, it will remove the service from the registry.

2.2. From the caller's point of view:

When starting, the caller of the service looks up the address of the service provider and other information from the service registry according to the service he subscribes to.

When a service consumed by a service caller is online or offline, the registry will inform the caller of the service

When the service caller goes offline, unsubscribe.

3. Network transmission

3.1. Serialization

When the application on machine An initiates a RPC call, the calling method and its input parameters need to be transmitted to machine B through the underlying network protocol such as TCP. Because the network protocol is based on binary, all the parameter data we transmit need to be serialized (Serialize) or marshal (binary) before they can be transmitted in the network. The serialized or grouped binary data is then sent to the B machine through addressing operations and network transmission.

3.2. Deserialization

When the B machine receives the request from the application of the A machine, it needs to deserialize the received parameters and other information (the reverse operation of serialization), that is, to restore the binary information to the expression in memory. Then find the corresponding method (part of addressing) to call locally (usually by generating proxy Proxy, usually JDK dynamic proxy, CGLIB dynamic proxy, Javassist generated bytecode technology, etc.), and then get the return value of the call.

4. Service call

Machine B gets the return value after making local calls (through proxy Proxy and reflection calls). At this time, the return value needs to be sent back to machine A, which also needs to be serialized, and then the binary data is sent back to machine A through network transmission. When machine A receives these return values, it performs the deserialization operation again and returns to the in-memory expression. Finally, it is handed over to the application on machine A for related processing (usually business logic processing operation).

This is the end of the content of "what are the latest version of Dubbo interview questions in 2021". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report