What is the dubbo
Dubbo is a distributed framework for remote service invocation. Its core parts include: Cluster fault tolerance: provides transparent remote procedure call based on interface method, including multi-protocol support, and cluster support for soft load balancing, failure tolerance, address routing, dynamic configuration, etc. Remote communication: Provides an abstract encapsulation of a variety of long-connection-based NIO frameworks, including multiple threading models, serialization, and request-response mode of information exchange. Automatic discovery: Based on registry directory services, service consumers can dynamically find service providers, address transparency, and service providers can smoothly add or subtract machines.
What can Dubbo do
Transparent remote method invocation, which calls remote methods as if they were local methods, requires simple configuration and no API intrusion. The soft load balancer and fault tolerance mechanism can replace hardware load balancers such as F5 on the Intranet, reducing costs and single points. Automatic service registration and discovery, no longer need to write the service provider address, the registry based on the interface name query service provider IP address, and can smoothly add or remove service providers.
1. What communication framework is used by default? Is there any other choice?
A: The Netty framework is also recommended by default, as is Mina.
2. Is the service invocation blocking?
A: It is blocked by default and can be called asynchronously, if there is no return value.
3. What registry is generally used? Is there any other option?
A: It is recommended to use the ZooKeeper registry, as well as the Multicast, Redis, and Simple registries.
ZooKeeper nodes are maintained in a tree-like structure, and each node is identified and accessed through a path. In addition, each node also has its own information, including: data, data length, creation time, modification time, and so on.
What serialization framework is used by default, and what else do you know?
A: Hessian serialization is used by default. There are also Duddo, FastJson, and Java serialization. Hessian is a service framework that transmits data in binary format. It is lighter and faster than traditional SOAP Web Services.
Analysis of Hessian Principle and Protocol
The HTTP protocol dictates how data is transferred, and Hessian can’t change that much:
-
1) The interaction between client and server in Hessian is based on HTTP-POST mode. 2) Hessian encapsulates auxiliary information in HTTP headers, such as “authorization token”. We can encapsulate “security verification” and “meta data” based on HTTP-headers. Hessian provides a simple “verification” mechanism.
-
3) Hessian interaction core data, such as “method called” and parameter list information, will be sent directly through the body of the POST request as a byte stream.
-
4) The server response data of Hessian will be directly output by byte stream in response.
Hessian’s protocol itself is not complicated, so I won’t repeat it here; A protocol is a constraint on the format of data. The client serializes the request information into byte sequences and sends it to the server. The server deserializes the data into “objects” according to the protocol, and then executes the specified method and serializes the return value of the method into byte streams. The response is sent to the client, who, according to the protocol, reverse-sequence the byte stream into an “object”.
5. What is the principle that service providers can achieve failure kick out?
A: Service failure kicks out the temporary node principle based on ZooKeeper.
6. How does the launch of the service not affect the old version?
A: Use multi-version development, does not affect the old version. Add version to the configuration for version differentiation
7. How to solve the problem of long service invocation chain?
A: You can combine zipkin for distributed service tracking.
8. What are the core configurations?
The core configuration has
-
dubbo:service/
-
dubbo:reference/
-
dubbo:protocol/
-
dubbo:registry/
-
dubbo:application/
-
dubbo:provider/
-
dubbo:consumer/
-
dubbo:method/
9. What protocol does Dubbo recommend?
A: The dubbo protocol is used by default.
10. Can a service be directly connected with multiple registrations of the same service?
A: You can directly connect to a service by modifying the configuration, or directly connect to a service through Telnet.
11. How does Dubbo solve the security mechanism?
Dubbo prevents users from directly connecting by bypassing the registry through token tokens, and then manages authorization in the registry. Dubbo provides a blacklist and whitelist that controls who the service allows to call.
12, cluster fault tolerance how to do?
A: You are advised to use Failover to perform automatic switchover. By default, try again twice for other servers. You are advised to use Failfast for write operations. If a call fails, an error message is reported immediately.
13. What are the problems encountered in the process of use? How is it solved?
1. If both XML and properties files are configured, the configuration in Properties is invalid
Properties takes effect only if XML is not configured.
Dubbo checks to see if dependencies are available at startup. If they are not available, an exception is thrown to prevent spring initialization from completing. The check property defaults to true.
Set check to false when testing services that do not care or have cyclic dependencies
** Add VX: YDT939 free access to all interview questions and answers, more Java interview topics free access, there is always a book you need **
3. For the convenience of development and testing, there is an offline registry of all services available. At this time, if there is a service provider registered under development, it may affect the normal operation of consumers.
Solution: Let the service provider developer, only subscribe to the service, but not register the service under development, test the service under development by direct connection. Set the register property of the Dubbo: Registry tag to false.
4. Spring 2.x initializes deadlock issues.
In spring resolved to dubbo: service, it has exposed the outward, and spring is in the then initialize other beans, if you have any request at this time to come in, and the implementation of the service class for calling applicationContext. GetBean (). The getBean thread and The Spring initialization thread lock in a different order, resulting in a thread deadlock, unable to serve, and unable to start.
Solution: don’t use in the implementation of the service class applicationContext. The getBean (); If you do not want to rely on the configuration order, you can set the deplay property of the Dubbo :provider to -1 so that dubbo will not expose the service until the container is initialized.
5. The service fails to be registered
Check to see if dubbo jars are in the classpath and if there are duplicate jars
Check that the Spring configuration for the exposed service is loaded
Test network connectivity to the registry on the service provider machine
6. RpcException: No provider available for remote Service is displayed
Indicates that no service provider is available,
1). Check whether the connected registry is correct
2). Check whether the corresponding service provider exists in the registry
3). Check whether the service provider is running properly
7. The Message sending Failed exception is displayed
It is usually the incoming and outgoing parameters of the interface methods that do not implement the Serializable interface.
14. The difference between a dubbo and a dubbox?
A: Dubbox is based on dubbo, dangdang has made some extensions, such as adding restful service calls, updating open source components, etc.
15. What other distributed frameworks do you know?
A: There are spring Cloud for Spring, Thrift for Facebook, Finagle for Twitter, etc.
16. Which protocols does Dubbo support? Application scenarios of each protocol, advantages and disadvantages?
Dubbo: Single long connection and NIO asynchronous communication, suitable for large concurrent and small data volume service calls, and far more consumers than providers. TCP, asynchronous, Hessian serialization;
Rmi: using JDK standard RMI protocol implementation, transmission parameters and return parameter objects need to implement Serializable interface, the use of Java standard serialization mechanism, the use of blocking short connection, transmission packet size mixed, the number of consumers and providers is about the same, can transfer files, transmission protocol TCP. Multiple short connections, TCP transport, synchronous transport, suitable for general remote service calls and RMI interoperation. Java serialization suffers from security vulnerabilities when relying on earlier versions of the 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 transmission, synchronous transmission, suitable for system integration and cross-language call; HTTP: A remote invocation protocol based on HTTP form submission, implemented using Spring’s HttpInvoke. Multiple short connections, transport protocol HTTP, mixed sizes of incoming parameters, more providers than consumers, need to give application and browser JS calls; Hessian: Integrated Hessian service, based on HTTP communication, using Servlet to expose the service, Dubbo embedded Jetty as the default implementation of the server, providing interoperation with Hession service. Multiple short connections, synchronous HTTP transfers, Hessian serialization, large incoming parameters, more providers than consumers, greater provider pressure, passable files;
Memcache: memcached based RPC protocol redis: Redis based RPC protocol
17. What are the load balancing policies of Dubbo cluster
Dubbo provides common cluster policy implementations and pre-extension points implement them themselves.
Random LoadBalance: Provider policies are randomly selected to dynamically adjust provider weights. The cross section collision rate is high, the more calls, the more uniform distribution;
RoundRobin LoadBalance: Indicates that provider policies are evenly distributed, but requests are accumulated.
LeastActive LoadBalance: LeastActive LoadBalance: the LeastActive call policy, the slower provider receives fewer requests; ConstantHash LoadBalance: a consistent Hash policy. Requests for the same parameters are always sent to the same provider. If a machine is down, it can be allocated to other providers based on virtual nodes to avoid drastic changes in providers.
18. How to solve the service invocation timeout problem
Dubbo will retry twice by default if the call to the service is unsuccessful. In this way, when the server processing time exceeds the timeout period, there will be repeated requests. For example, when sending emails, multiple repeated emails may be sent, and multiple repeated registration data will be inserted when performing registration requests. Then how to solve the timeout problem? The following
For the core service center, remove the Dubbo timeout retry mechanism and reevaluate the set timeout. The business process code must be placed on the server side, and the client side only does parameter validation and service invocation, not the global configuration instance of the business process
Of course, Dubbo’s retry mechanism is actually a very good QOS guarantee. Its routing mechanism will help you to route timeout requests to other machines, rather than the local attempt, so Dubbo’s retry machine can also guarantee the quality of service to a certain extent. But be sure to give a comprehensive assessment of online access.
** Add VX: YDT939 free access to all interview questions and answers, more Java interview topics free access, there is always a book you need **