Gossip Girlfriend wants to see Dubbo interview questions for a long time

Preface

Dubbo's overall introduction is almost the same. Today I will start the interview. I will list some common Dubbo interview questions. I will only focus on the important ones. I will not mention the ones that are too simple.

Not only give you the answer to the interview question, but also analyze the reason why the interviewer asked the question, which is his inner activity.

What do you want to ask from you? What answer do you want? What pit do you want to dig for you to jump?

text

Do you know what RPC is?

Generally, interviewers will enter the field with such questions. The completion of the interview is also a step-by-step process, so you don't have to be too impatient to talk about Barbara at the beginning. You must grasp the key points and briefly explain first.

And from this question, the interviewer can identify whether your daily work content has not even been exposed to RPC, or is it just one-stop Spring MVC?

It is true that many students have never contacted RPC, and it is normal that some outsourcing or some small projects are not contacted, but you don't know that this thing is two concepts.

It can be reflected from the side that this person shouldn’t study much outside of work. He doesn’t even know RPC, so I can’t explain it. Basically, it’s cool, and the initial impression of you will be poor, unless you can have a bright eye from behind. which performed.

Answer: RPC is Remote Procedure Call, which corresponds to local procedure call.
Gossip Girlfriend wants to see Dubbo interview questions for a long time

Then why is there RPC, is HTTP bad?

At this time, the interviewer began to ask questions.

This question is actually very interesting. Some interviewers may not know themselves well, and then think they are very clear, so they ask this question, and there is another kind that is really clear. Asking this question is to make you jump into the hole.

Because RPC and HTTP are not at the same level, the two are not comparable in the strict sense and should not be compared. The question is to compare these two.

HTTP is only a transmission protocol, and the protocol only regulates a certain communication format, and RPC is earlier than HTTP, so I really want to ask why there is RPC and HTTP.

RPC contrasts with local procedure calls, which are used as communication between distributed systems. It can be transmitted using HTTP or based on TCP custom protocol.

So you have to mention that these two are not at the same level and are not comparable, and then show it. It can be said that the HTTP protocol is relatively redundant, so most of the RPCs are based on the TCP custom protocol, and the customized one is best for you. of.

Of course, there are also RPC frameworks based on the HTTP protocol. After all, HTTP is an open protocol and is more general. For example, HTTP2 has been compressed accordingly, and the calls between systems are all in the intranet, so the impact will not be great.

After this wave of answers, the interviewer will think that you have something, start to be a little interested in you, and start to get into you.
Gossip Girlfriend wants to see Dubbo interview questions for a long time

Tell me about your knowledge of Dubbo?

The interviewer will first ask a bigger question, and then find some breakthroughs in your answers to ask in depth, so this question is actually quite open. You can answer from the historical development or from the overall structure.

If you answer from the perspective of historical development, it means that you are also very concerned about some open source software, and the side can also reflect your embrace of open source.

If you answer from the overall structure, it is undoubtedly possible. It is recommended to say it in a simple way first and wait for further questions.

Historical development, this is actually mentioned in the previous article of C:

Dubbo is a Java-based RPC framework open sourced by Alibaba. It was silent for a while, but in 2017 Alibaba restarted the maintenance of Dubbo.

And in 2018, it merged with Dangdang's Dubbox, entered the Apache incubator, and officially became the top Apache project after graduation in 2019.

At present, the main maintenance of the Dubbo community is 2.6.x and 2.7.x. The 2.6.x version is mainly for bug fixes and a few feature enhancements. It is a stable version.

The release of version 2.7.5 is considered by Dubbo to be a milestone release, which supports gRPC and has improved performance by 30% (if you don't understand gRPC and why the performance is improved, don't talk about it, don't dig yourself).

The latest version 3.0 explores the cloud-native direction.

Note that if you are not familiar with the various versions of history and don’t know what the latest version is going to do, don’t answer in this direction. If you are lucky, the interviewer doesn’t know much about it. He may not ask, so luck. Just asked.

The overall structure, as mentioned above, should be simple. Wait for follow-up questions, because if the interviewer understands, he will definitely ask in-depth. If you don't understand you, Barbara will feel nothing.
Gossip Girlfriend wants to see Dubbo interview questions for a long time

Just briefly mention these roles now.

Node role description
Consumer needs to call the service consumer of the remote service.
Registry Registry
Provider Service Provider
Container Service Provider Container
Monitor Monitoring Center For
example, Dubbo is divided into the above roles in general, and the respective functions are xxxx.

Pause here to see the interviewer's response, if there is no answer, continue with the general process.

First, the service provider starts and then registers the services it can provide with the registry.

The service consumer Consumer starts to subscribe to the registration center for the services it needs. Then the registry notifies the consumer of the provider's meta-information. After the consumer has obtained the provider's address from the registry, it can select a provider through load balancing and call it directly.

After the service provider metadata changes, the registry will push the changes to the service consumers.

Both the service provider and the consumer will record the number of calls and time in the memory, and then send statistical data to the monitoring center regularly.

This is basically the case. If you have read C's Dubbo series of articles before, then you have read the source code, and you must be very clear about the series of processes, so you can say that you have read the Dubbo source code at the right time.

As we all know, reading the source code is definitely a bonus item, so this point is worth mentioning.

When the interviewer heard, the good guy has read the source code, right? Let’s talk about it.
Gossip Girlfriend wants to see Dubbo interview questions for a long time

Then began the combo.

After reading the source code, what about the process of service exposure?
The service exposure starts after the Spring IOC container is refreshed, it will be assembled into a URL according to the configuration parameters, and then local or remote calls are made according to the URL parameters.

Will pass proxyFactory.getInvoker, use javassist to perform dynamic proxy, encapsulate the real implementation class, and then use the URL parameter to select the corresponding protocol for protocol.export. The default is the Dubbo protocol.

When exposed for the first time, createServer will be called to create a Server. The default is NettyServer.

Then store the exporter obtained by export into a Map for later remote invocation and search, and then register the provider's information with the registry.

It's basically such a process. After all, it's almost the same. No one remembers the details.
Gossip Girlfriend wants to see Dubbo interview questions for a long time

After reading the source code, what about the process of service introduction?

There are two timings for the introduction of services, the first is the hungry man, and the second is the lazy man.

The hungry style is to be introduced after loading, and the lazy style is to start the introduction process only when the service is injected into other classes. The default is the lazy style.

It will first assemble the URL according to the configuration parameters. Generally speaking, we will configure the registry, so we will build the RegistryDirectory to register the consumer's information with the registry, and subscribe to the provider, configuration, routing and other nodes.

After knowing the provider's information, it will enter the introduction of the Dubbo protocol, create an Invoker, during which it will include NettyClient for remote communication, and finally wrap the Invoker through the Cluster. The default is FailoverCluster, and finally return to the proxy class.

It's almost done, and the key points are mentioned.

Don't be too detailed, don't say everything you know, it will not grasp the point, for example, you have to insert the above process, and there are three ways to introduce: local introduction, direct connection and remote introduction, and introduction through the registration center.

Then separately talk about what kind of local introduction, Barbara's will be very messy, so during the interview, it needs to be deleted, and you must go straight to the point.

In fact, what you really said should be more concise than what I said above. I'm afraid that everyone is not clear enough to say it in a little more detail.
Gossip Girlfriend wants to see Dubbo interview questions for a long time

After reading the source code, what about the service call process?

The method of calling an interface will call the proxy class generated before, and then select an invoker from the cluster through routing filtering and load balancing mechanism to initiate a remote call. At this time, the request and the ID of the request will be recorded and wait for the response from the server.

After receiving the request, the server will find the previously exposed and stored map through the parameters, get the corresponding exporter, and finally call the real implementation class, and then assemble the result to return. This response will bring the ID of the previous request.

After receiving this response, the consumer will use the ID to find the previously recorded request, and then after finding the request, the response is stuffed into the corresponding Future to wake up the waiting thread, and finally the consumer gets the response, and the process is completed.

The key is cluster, routing, load balancing, and Dubbo is asynchronous by default, so how does the request and response correspond.

Afterwards, I may also ask how Dubbo implements asynchronous transfer to synchronization. I have mentioned it in the article before C. Those who have forgotten can go back and have a look.

Do you know what SPI is?
This is another direction. From the above answer, whether it is from the Dubbo protocol, cluster, export method, etc., everywhere is not the shadow of SPI, so if you ask Dubbo questions, it is beyond doubt to ask SPI. Because SPI is everywhere in the source code, and SPI is also the cornerstone of Dubbo's scalability.

So there is no routine for this question, just answer it directly.

SPI is the Service Provider Interface, which is mainly used in the framework. The framework defines the interface. Different users have different requirements, so different implementations are needed. The SPI defines a specific location. The Java SPI agrees to be under the Classpath Create a file named after the service interface in the META-INF/services/ directory, and then record the fully qualified name of the specific implementation class provided by this jar package in the file.

Therefore, you can find the corresponding file through the interface, get the specific implementation class and load it, so that you can flexibly replace the specific implementation class.
Gossip Girlfriend wants to see Dubbo interview questions for a long time

Why does Dubbo not use JDK's SPI, but implement it by itself?

Asking this question is to see if you have an in-depth understanding, or have thought about it yourself, instead of looking rigidly at the source code, or looking at some knowledge points.

There are many points to think about, not just what the book says. You have to know the reasons for doing this, and what are the advantages and disadvantages. It is easy to see whether a person has memorized by rote or has his own thinking.

Answer: Because Java SPI traverses the SPI configuration file and instantiates all the implementation classes when looking for the extension implementation class. Assuming that the initialization process of an implementation class is resource-consuming and time-consuming, but you can’t use it in your code. There is a waste of resources.

Therefore, Dubbo implements an SPI by itself, assigns a name to each implementation class, uses the name to find the full qualified name of the corresponding implementation class in the file, then loads it and instantiates it, and loads it on demand.

This is a bonus. The interviewer is clapping his hands. It's pretty good.
Gossip Girlfriend wants to see Dubbo interview questions for a long time

Why Dubbo uses Javassist by default

Above you answered that Dubbo uses the Javassist dynamic proxy, so you are likely to ask why you want to use this proxy, and may also extend the dynamic proxy, ASM, and CGLIB of the JDK.

So this is also a point to pay attention to. If you are not very clear, then the above answer should not involve dynamic agents. If you are clear, you must mention it to induce the interviewer to ask you questions about dynamic agents. This is very important.

The interviewer needs to be induced. After all, he also wants to know how good you are in terms of excellence. You should also learn from each other for a win-win situation.

Let me answer why Javassist is used. It is simple, fast, and easy to generate bytecodes.

ASM is faster than Javassist, but not an order of magnitude faster. Javassist can generate bytecode only by concatenating strings, while ASM requires manual generation, which is costly and troublesome.

If you are asked to design an RPC framework, how?
Interviewers like to ask these kinds of questions to test the candidate's design ability, and whether they have a comprehensive understanding of a framework.

If you don’t usually think about it, the things you answer without thinking about it will be unorganized and will appear chaotic, but you don’t have to panic, don’t think about it comprehensively, answer very carefully, it’s not necessary, what the interviewer wants Are the key points.

You can start from the bottom up.

First of all, you need to achieve high-performance network transmission, you can use Netty to achieve, you don’t need to reinvent the wheel yourself, and then you need to customize the protocol. After all, remote interaction needs to follow a certain protocol, and then you also need to define a serialization protocol. After all, network transmission All are transmitted in binary streams.

Then you can develop a language for describing services, namely IDL (Interface description language), so that all services are defined in IDL, and then the framework is converted to a specific programming language interface, so that it can be cross-language.

At this time, the basic functions have been available recently, but they are only the most basic. Industrial-grade ones must be easy to use. Therefore, the framework needs to shield the users from the above details so that they cannot feel the difference between local calls and remote calls. So it needs proxy implementation.

Then you also need to implement the cluster function, so you need to perform functions such as service discovery and registration, so you need a registry. Of course, the details still need to be shielded.

Finally, a complete monitoring mechanism is needed, such as burying points to report the call status, etc., to facilitate operation and maintenance.

The prototype of such an RPC framework is almost the same.
Gossip Girlfriend wants to see Dubbo interview questions for a long time

At last

This is the end of the Dubbo series. In fact, there are still a lot of details. If you want to write, there are still a lot to write.

However, the overall context is clear, and the subsequent practice still depends on everyone's efforts.

There are definitely more interview questions. Interview questions are endless. Real interviews must grasp the points you answered to dig deeper, so I can't simulate them. I can only tell you the general key points and try to figure out the interviewer. Mental activity.

When the interviewer asks you, you can try to figure out what he wants to ask. This is very important.

Don’t panic during the interview. You and the interviewer are equal, and the interviewer may not be good. Sometimes the interview is a matter of luck. Don’t be discouraged if the interview fails. Discord, this is normal.

Come on.

Ramble
recently invited to participate in Huawei HC2020, a lot of friends also shot a lot of material, I was non-stop clip, hope to soon meet with you.

This is Ao Bing. Thank you for your Sanlian. The more you know, the more you don’t know. See you next time.

Guess you like

Origin blog.51cto.com/14689292/2545232