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 Dubbo interview questions and answers?

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "what are the Dubbo interview questions and answers". In the operation of actual cases, many people will encounter such a dilemma. Next, 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!

1. What is Dubbo?

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

RPC refers to the remote invocation protocol, which means that two servers exchange data.

2. The origin of Dubbo?

With the rapid development of the Internet, the scale of Web applications continues to expand, which generally goes through the following four stages of development.

① single application architecture

When the website traffic is very small, only one application is needed to deploy all the functions together.

② Vertical Application Architecture

When the number of visits increases gradually, a single application is divided into multiple applications according to the business line to improve efficiency. At this point, the Web framework (MVC) used to accelerate front-end page development is the key.

③ distributed service architecture

When there are more and more vertical applications, the interaction between applications is inevitable, the core business will be extracted as an independent service, and gradually form a stable service center, so that the front-end applications can respond to the changing market demand more quickly.

At this point, the distributed service framework (RPC) for improving business reuse and integration is the key.

④ Mobile Computing Architecture

When there are more and more services, the evaluation of capacity and the waste of small service resources gradually appear, so it is necessary to add a scheduling center to manage cluster capacity in real time based on access pressure to improve cluster utilization.

At this point, the resource scheduling and governance center (SOA) used to improve machine utilization is the key.

3. The main application scenarios of Dubbo?

Transparent remote method invocation, calling remote methods as if they were local methods, with simple configuration without any API intrusion.

Soft load balancing and fault-tolerant mechanism can replace F5 and other hardware load balancers in the intranet to reduce costs and reduce a single point.

Automatic service registration and discovery eliminates the need to write down the address of the service provider. The registry queries the IP address of the service provider based on the interface name, and can smoothly add or delete service providers.

4. The core function of Dubbo?

The main functions are as follows:

① 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, soft load balancing, failure tolerance, address routing, dynamic configuration and other cluster support.

③ Registry: service registration, based on registry directory service, enables service consumers to look up dynamically, makes addresses transparent, and enables service providers to smoothly increase or decrease machines.

5. The core components of Dubbo?

① Provider: the provider of the exposed service

② Consumer: the service consumer that invokes remote services

③ Registry: registry for service registration and discovery

④ Monitor: the monitoring center that calculates the call time and call time of the service

⑤ Container: service running container

6. The process of Dubbo service registration and discovery?

Process description:

① Provider (provider) binds the specified port and starts the service

② means that the donor connects to the registry and sends local IP, port, application information and service information to the registry for storage.

③ Consumer (consumer), connect to the registry and send application information and requested service information to the registry

The ④ registry matches the corresponding list of providers according to the service information requested by the consumer and sends it to the Consumer application cache.

⑤ Consumer initiates a call based on the cached consumer list when it initiates a remote call.

⑥ Provider status changes are notified to the registry in real time and pushed to Consumer in real time by the registry.

Reasons for the design:

① Consumer is decoupled from Provider, and both sides can increase or decrease the number of nodes horizontally.

The ② registry can be a peer-to-peer cluster for itself, adding or decreasing nodes dynamically, and when any one is down, it will automatically switch to the other.

③ is decentralized, and both parties do not directly rely on the registry. Even if the registry is down completely, it will not affect the service invocation within a short period of time.

The ④ service provider is stateless, and its use will not be affected when any one of them goes down.

What is the architecture of 7.Dubbo?

The Dubbo framework design is divided into 10 layers:

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

② configuration layer (Config): the external configuration interface is centered on ServiceConfig and ReferenceConfig. You can directly new configuration classes or generate configuration classes through spring parsing configuration.

③ service proxy layer (Proxy): transparent proxy of the service interface, generating client-side Stub and server-side Skeleton of the service, with ServiceProxy as the center and ProxyFactory as the extended interface.

④ service registry layer (Registry): encapsulates the registration and discovery of service addresses, with service URL as the center, and extended interfaces for RegistryFactory, Registry and RegistryService. There may be no service registry, where the service provider directly exposes the service.

⑤ cluster layer (Cluster): encapsulates routing and load balancing of multiple providers, bridges the registry, takes Invoker as the center, and extends the interfaces for Cluster, Directory, Router and LoadBalance. Multiple service providers are combined into a single service provider, which is transparent to the service consumer and only needs to interact with one service provider.

⑥ 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 (Protocol): encapsulates RPC calls, focusing on Invocation and Result, and extending interfaces for Protocol, Invoker, and Exporter. Protocol is the service domain, it is the main functional entry for Invoker exposure and reference, and it is responsible for the lifecycle management of Invoker.

Invoker is a physical domain, it is the core model of Dubbo, other models rely on it, or converted to it, it represents an executable, you can make invoke calls to it, it may be a local implementation, it may be a remote implementation, or a cluster implementation.

⑧ information exchange layer (Exchange): encapsulates the request response mode, changes synchronously to different steps, takes Request and Response as the center, and extends the interfaces for Exchanger, ExchangeChannel, ExchangeClient and ExchangeServer.

⑨ Network Transport layer (Transport): abstract mina and netty are unified interfaces, with Message as the center, and the 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. What protocols does Dubbo support, the application scenarios of each protocol, and its advantages and disadvantages?

① dubbo: single persistent connection and NIO asynchronous communication, 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

② rmi: implemented using the rmi protocol of the JDK standard, the transmission parameters and return parameter objects need to implement the ③ Serializable interface, use the java standard serialization mechanism, use blocking short connections, mixed transmission packet size, the number of consumers and providers is about the same, transferable files, transfer protocol TCP.

Multiple short connections, TCP protocol transport, synchronous transmission, suitable for conventional remote service invocation and rmi interoperation. There is a security vulnerability in java serialization when relying on an earlier version of Common-Collections package

④ webservice: remote call protocol based on WebService, integrated with CXF implementation, providing interoperability with native WebService. Multiple short connections, based on HTTP transport, synchronous transmission, suitable for system integration and cross-language calls

⑤ http: a remote call 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 for 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, provides 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 based on memcached

⑧ redis: RPC Protocol based on redis

9. What protocol does dubbo recommend?

Dubbo protocol is used by default

10. What registries does Dubbo have?

① Multicast registry: the Multicast registry does not need any central node, as long as the broadcast address, service registration and discovery can be carried out. Implementation of Multicast Transmission based on 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 model notifies data changes

④ Simple registry

11. Service governance of Dubbo?

It is difficult to configure too many service URL of ①

In the case of excessive pressure on ② load balancer distribution nodes, you also need to deploy clusters.

③ service dependencies are chaotic and the startup sequence is not clear

Due to too many ④ services, it is difficult to analyze performance indicators and need to be monitored.

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

Yes, 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.

13. The relationship between Dubbo and Spring?

Dubbo adopts full Spring configuration mode and accesses the application transparently without any API intrusion to the application. You only need to load the configuration of Dubbo with Spring, and Dubbo is loaded based on Schema extension of Spring.

14. What communication framework does Dubbo use?

The NIO Netty framework is used by default

15. What load balancing strategies are provided by Dubbo clusters?

① Random LoadBalance: randomly select the provider policy, which is conducive to dynamically adjust the provider weight. The higher the cross section collision rate is, the more the number of calls is, the more uniform the distribution is.

② RoundRobin LoadBalance: round-robin selection of provider policies, evenly distributed, but with the problem of request accumulation

③ LeastActive LoadBalance: least active invocation strategy to address slow providers receiving fewer requests

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

16. What are the cluster fault tolerance solutions for 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: calls multiple servers in parallel and returns as soon as one succeeds. 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.

17. Dubbo's default cluster fault tolerance scheme?

Failover Cluster

18. What serialization methods does Dubbo support?

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

19. How to set the Dubbo timeout?

There are two ways to set the Dubbo timeout:

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

The consumer side of the ② service 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. How to solve the problem of service call timeout?

When the dubbo invokes the service unsuccessfully, it retries twice by default.

21. How does Dubbo solve the problem in terms of security mechanism?

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.

22. What's the difference between dubbo and dubbox?

Dubbox has made some extensions based on dubbo, such as adding services that can be called by restful, updating open source components and so on.

23. What other distributed frameworks are there besides Dubbo?

What we are familiar with is Spring cloud. Of course, there are many similar frameworks abroad.

24. 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. In addition, relying on the advantages of Spirng and Spirng Boot, the goals of the two frameworks are not consistent at the beginning. Dubbo positioning service governance and Spirng Cloud is an ecology.

25. What's the difference between dubbo and spring cloud?

The biggest difference: the bottom layer of Dubbo uses a NIO framework such as Netty, which is transmitted based on TCP protocol, together with Hession serialization to complete RPC communication.

SpringCloud is based on Http protocol + Rest interface to call remote process communication, relatively speaking, Http requests will have larger messages and occupy more bandwidth. However, REST is more flexible than RPC, and the dependence of service providers and callers only depends on a contract, and there is no strong dependence at the code level, which is more appropriate in a micro-service environment that emphasizes rapid evolution. As for whether to focus on communication speed or convenience and flexibility, specific consideration should be given to the specific circumstances.

This is the end of the content of "Dubbo interview questions and answers". Thank you for your 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