Have feelings, have dry goods, wechat search [three prince Ao Bing] pay attention to this different programmer.

This article has been included in GitHub github.com/JavaFamily, there are a line of large factory interview complete test sites, information and my series of articles.

preface

Dubbo is almost the whole introduction, today will start the interview process, I will list some common Dubbo interview questions, only focus on the important, some too simple I will not mention.

Not only will it give you the answer to the interview question, but it will also give you an insight into why the interviewer is asking the question, which is what’s going on in their mind.

What do I want to get out of you? What answer do you want? What kind of hole do you want to dig?

Began to show

Do you know what RPC is?

Most interviewers will start with questions like this, and the interview process will be gradual, so you don’t have to be too hasty to start with a lot of Barbara, but to grasp the key points and briefly explain first.

And the interviewer can tell from this question whether you have no contact with RPC in your daily work, is it just a dragon of Spring MVC?

Indeed, there are a lot of students who have never been exposed to RPC, which is quite normal, such as some outsourcing or some small projects. However, not being exposed to RPC in daily life is a different concept from not knowing it.

It can reflect from the side that this person should not learn much after work, even RPC do not know, so how can not say past, basically cool, the initial impression of you is poor, unless you can have a bright performance from the back.

A: Remote Procedure Call is the equivalent of a local Procedure Call.

So why RPC? HTTP is bad?

That’s when the interviewer starts asking questions.

This is actually a very interesting question. Some interviewers may think they know it because they don’t know it, or they may really know it because they’re asking it to get you to jump into a trap.

Since RPC and HTTP are not on the same level, the two are not strictly comparable and should not be compared.

HTTP is only a transport protocol, protocol is only a specification of a certain format of communication, and RPC is prior to HTTP, so the real question is also asked why HTTP has RPC.

RPC contrasts with local procedure calls and is used as communication between distributed systems, which can be transmitted over HTTP or over TCP custom protocols.

Therefore, you should first point out that these two are not at the same level and are not comparable, and then show that HTTP protocol is relatively redundant, so RPC is mostly based on TCP custom protocol, and customized is the most suitable for their own.

Of course, there are RPC frameworks based on HTTP protocol, after all, HTTP is a public protocol, relatively general, like HTTP2 has done corresponding compression, and calls between systems are on the internal network, so the impact is not great.

After this wave of answers, the interviewer will feel that you have something, start to be a little bit interested in you, start to dig into you.

What do you know about Dubbo?

The interviewer is going to start with a big question, and then they’re going to take your answer and find a way to dig deeper, so it’s kind of open-ended, you can answer it in terms of history, you can answer it in terms of structure.

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

If you answer from the overall structure, there is no doubt that it is also possible, it is suggested that the first shallow, waiting for questioning.

Historical development, which has already been mentioned in c’s previous article:

Dubbo is an open source Java-based RPC framework developed by Alibaba. After a period of silence, Dubbo was restored by Alibaba in 2017.

In 2018, it merged with Dangdang Dubbox and entered the Apache incubator. After graduation in 2019, it officially became an Apache top-level project.

Currently, Dubbo community mainly maintains two major versions of 2.6.x and 2.7.x. 2.6.x is a stable version with bug fixes and a few feature enhancements.

The release of version 2.7.5 was considered a milestone release by Dubbo, with support for gRPC and a 30% performance increase (don’t dig a hole for yourself if you don’t know gRPC and why).

The latest version, 3.0, explores the cloud native direction.

If you are not familiar with the various versions of history and do not know what the latest version of history is about, don’t ask this question.

The overall structure, the above also mentioned the first shallow said, such as cross-questioning, because the interviewer if understand, he will certainly ask in-depth, if do not understand you Barbara a bunch of he did not feel.

Just briefly mention the current cast of characters.

node The role that
Consumer The service consumer that needs to invoke the remote service
Registry The registry
Provider Service Provider
Container The container in which the service runs
Monitor The monitoring center

For example, Dubbo is divided into several roles, each of which is XXXX.

Pause here to see how the interviewer is responding, and if not, move on to the general process.

The service Provider starts up and registers the services it can provide with the registry.

The service Consumer starts to subscribe to the registry for the services it needs. The registry then notifies the Consumer of the Provider meta-information, and since the Consumer has obtained the Provider’s address from the registry, it can choose a Provider to invoke directly through load balancing.

The registry then pushes the changes to the service consumer if the service provider metadata changes.

Both service providers and consumers record the number and time of calls in memory and periodically send statistics to the monitoring center.

To this basically almost, if before read c Dubbo series of articles, then even if read the source code, certainly for a series of process is very clear, so at the appropriate time can say that they read Dubbo source code.

As we all know, reading the source code is definitely a plus, so this is something to mention.

Interviewer a listen, good guy read the source code, say.

Then the combos began.

Read the source code, what about the process of service exposure?

The service is exposed when the Spring IOC container is refreshed and the URL is assembled based on configuration parameters, which are then used to make local or remote calls.

Proxyfactory. getInvoker, javassist is used to carry out dynamic proxy, encapsulate the real implementation class, and then select the corresponding protocol by URL parameter to carry out protocol.export, the default is Dubbo protocol.

CreateServer is called on first exposure to create the Server, which is NettyServer by default.

Export’s output is then put into a Map for later remote calls to look up, and the provider’s information is registered with the registry.

Basically is such a process, said these almost, too fine who all remember not.

Read the source code, then talk about the process of service introduction?

There are two kinds of service introduction timing, the first kind is hungry, the second kind is lazy.

Hungry means that the service is imported as soon as it is loaded. Lazy means that the import process is only started when the service is injected into other classes. Default is lazy.

The URL is first assembled according to the configuration parameters. In general, we configure the registry, so RegistryDirectory is built to register the consumer 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 Dubbo protocol, create Invoker, including NettyClient for remote communication, and finally wrap Invoker with Cluster, FailoverCluster by default, and finally return the proxy class.

That’s about it. I’ve covered all the key points.

Do not be too detailed, do not say what you know, this will miss the point, such as the above process you want to insert, import in three ways: local import, direct remote import, import through the registry.

And then what is the local introduction, Barbara’s will be very messy, so you need to cut out the interview, to the point.

In fact, it should have been a little bit more concise than what I said above, in case it was a little bit more detailed.

Read the source code, then talk about the process of service invocation?

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

The server accepts the request and finds the map that was exposed by its arguments, gets the corresponding EXPORTER, and eventually invokes the real implementation class. The result is assembled and returned with the ID of the previous request.

After receiving the response, the consumer will find the previously recorded request through the ID, and then plug the response into the corresponding Future after finding the request, wake up the waiting thread, and finally the consumer gets the response and the process is finished.

The key is cluster, routing, load balancing, and Dubbo is asynchronous by default, so how requests and responses correspond.

Later, they may also ask Dubbo how to realize the asynchronous to synchronous, etc., as mentioned in the article before C, students who forget can go back to see.

Do you know what SPI is?

This is another direction, from the above answer, whether it is from the Dubbo protocol, cluster, what export method is everywhere is SPI shadow, so if the question is about Dubbo, ask SPI is no doubt, because SPI is everywhere in the source code, And SPI is the cornerstone of Dubbo’s scalability.

So there’s no trick to this question, just answer it.

SPI is a Service Provider Interface, which is mainly used in the framework. The framework defines the Interface. Different users have different requirements and therefore need different implementations. The Java SPI convention creates a file named after the service interface in the META-INF/services/ directory of the Classpath, which records the fully qualified name of the concrete implementation class provided by the JAR package.

So you can find the corresponding file through the interface, obtain the specific implementation class and then load, so that the flexible replacement of the specific implementation class.

Why Dubbo doesn’t use the JDK’s SPI instead of implementing it itself?

Ask this question is to see you have in-depth understanding, or oneself thought, not rigid see source code, or see a few knowledge points.

A lot of it is thinking, it’s not just what the book says, you need to know why you’re doing it, what’s good and what’s bad, it’s easy to see if someone is rote memorizing or has their own thinking.

A: Because Java SPI iterates through the SPI configuration file and instantiates the entire implementation class when looking for an extension implementation class, it is a waste of resources to assume that an implementation class initialization process is expensive and time-consuming, but you don’t need it in your code.

So Dubbo implemented an SPI on its own, gave each implementation class a name, went to the file by name to find the fully qualified name of the corresponding implementation class and loaded the instantiation, loading it on demand.

This answer came out extra points, the interviewer in the heart of the clap, good good something.

Why does Dubbo use Javassist by default

Dubbo uses a Javassist dynamic proxy, so you’ll probably ask why you use this proxy, and probably also include JDK dynamic proxies, ASM, and CGLIB.

So that’s one of the things to be careful about, if you’re not sure you should not mention dynamic agency, if you are sure you should, to induce the interviewer to ask you about dynamic agency, which is very important.

The interviewer needs to be coaxed. After all, he wants to know how good you are at what you do best.

To answer why you use Javassist, it’s simple: it’s fast and easy to generate bytecode.

ASM is faster, but not an order of magnitude faster, than Javassist, which generates bytecode using string concatenation, whereas ASM generates bytecode manually, which is expensive and cumbersome.

If you were to design an RPC framework, how would you do it?

These are the kinds of questions that interviewers like to ask to test a candidate’s design skills and whether he or she has studied all aspects of a framework.

If you don’t think about it, if you don’t think about it in this way it’s going to be disorganized, it’s going to be disorganized, but you don’t need to panic, you don’t need to think about it thoroughly, you don’t need to answer it carefully, there’s no need, the interviewer is looking for the key points.

You can start from the bottom up.

First of all, we need to achieve high-performance network transmission, which can be achieved by using Netty instead of repeating the wheel. Then, we need to customize the protocol. After all, remote interaction needs to follow certain protocols, and then we need to define the serialization protocol.

Then you can develop a set of service description language, namely IDL (Interface Description Language), so that all services are defined in IDL, and then converted by the framework into a specific programming language Interface, so that it can cross languages.

At this point, the basic functionality has been recently, but it is only the most basic, industrial first to be easy to use, so the framework needs to shield the above details from users, so that they do not feel the difference between local and remote calls, so the need for proxy implementation.

Then also need to achieve cluster function, so to service discovery, registration and other functions, so the need for a registry, of course, the details still need to shield.

Finally, a perfect monitoring mechanism is also needed to report and call the situation of buried points, which is convenient for operation and maintenance.

That would be a good idea for an RPC framework.

The last

That’s the end of the Dubbo series, but there’s a lot of detail, and there’s certainly a lot to write about.

However, the overall context is clear, and the future practice still depends on your own efforts.

The interview questions are more than this, the interview questions are endless, the real interview is definitely to grasp the point of your answer to dig deeply, so I can not simulate, I can only tell you the general key points, and try to figure out the interviewer’s psychological activities.

It’s important to try to figure out what the interviewer is trying to ask you.

Don’t panic during the interview, you and the interviewer are equal, and the interviewer is not necessarily you good, and sometimes the interview is luck, the interview failed also don’t be discouraged, change a good, sometimes is the aura of conflict, this is very normal.

Come on.

omg

I’m Aobing, the more you know, the more you don’t know, thank you for your talent: likes, favorites and comments, we’ll see you next time!


This article is constantly updated. You can search “Santaizi Aobing” on wechat and read it for the first time. Reply [Information] There are the interview materials and resume templates for first-line big factories prepared by me.