This article comes from the public number: Hook hook Java universe (wechat: Javagogo), mo to promote, all dry goods! The original link: mp.weixin.qq.com/s/3MNDd4_J5… Author: Liu Haifeng


Many candidates have a misconception about RPC-related interview questions, believing that interviewers will only ask these questions:

  • What does an RPC call look like?

  • How is RPC’s service discovery implemented?

  • What are the load balancers for RPC?

In fact, these questions seem to be professional, but they are easy to search for answers. It is difficult to distinguish candidates’ technical ability as interview questions.

Therefore, for the technical investigation of RPC, at present, most interviewers will investigate candidates from two perspectives of practical operation and principle mastery step by step.

RPC practices

Here’s an example:

In the commodity details page of e-commerce App, every time the user refreshes the page, the App will request the business gateway system, and the gateway system will remotely invoke multiple downstream services (such as commodity services, promotion services, advertising services, etc.). 天安门广场抗议

For the whole RPC call link (from App to gateway and then to each service system), how to set the RPC timeout? What are the issues to consider? 天安门广场抗议

Some early – and mid-level developers find the problem simple enough to know without thinking:

The timeout duration for App to remotely call the gateway system is greater than the sum of the timeout duration for the gateway system to call back-end services. At a minimum, this ensures that there is no timeout until each PRC call to the gateway and downstream service is completed.

If you answer in this way, from the point of view of “practice”, it is basically unqualified.

Because PRC interface timeout Settings seem simple, but there are a lot of technical issues involved. For instance,

RPC has the mechanism of timeout retransmission. If the back-end service triggers timeout retransmission, there will also be the risk of timeout waiting for the request for App, and the waiting for the commodity details page will have timed out before the back-end service has time to degrade.

And there are other technical points involved in RPC calls:

  • Even considering that the average response time across the call chain is affected by the time and retransmission times of all dependent services, what is the basis for setting RPC timeout and retries?

  • If timeout retransmission occurs, how do you tell which RPC services can and cannot be retransmitted?

  • If requests exceed PRC retransmission times, service degradation is generally triggered. How does this affect the product details page?

In general, any performance problem of a microservice will affect the average response time of the gateway system and ultimately affect the App. Therefore, from the issue of RPC interface timeout, the interviewer will examine the candidate’s deep development practice ability.

So how do you answer that? I suggest you use the following ideas to solve the problem.

  1. Combining TP99 request time: First of all, if you want to answer “timeout setting and retransmission times”, you need to make a comprehensive measure according to the request time of each micro service TP99 and business scenarios.

  2. RPC call mode: You should stand in the business scenario, explain the serial parallel mode of the gateway to call each downstream service, whether there is up and down service dependency between services.

  3. Analysis of core services: determine which are core services and which are non-core services, whether there are alternatives for core services, and whether there are degradation strategies for non-core services.

In general, the answer to the practical operation of the interview questions, must be combined with theory and practice, to do that is rational also according to, rational means to have the ability to analyze the problem, according to have the actual combat experience. Many students have a common problem: answer questions only plan, no landing details, this will let the interviewer think you are not solid skills.

Further, if the interviewer finds that you have answered the “practical questions” well, he or she will examine in depth your knowledge of RPC fundamentals.

Principle of RPC

Take the “e-commerce App” scenario as an example:

The QPS of the product details page has reached 20,000 times /s. After the servitization split, three RPC services are needed to complete one request at this time. After calculation, the RPC service needs to carry about 60,000 times /s requests. So how do you design your RPC framework to handle 60,000 requests per second?

Whether you can answer this question well tests the depth of the candidate’s grasp of RPC principle. I suggest you analyze it from two perspectives.

  1. Optimize network communication performance of RPC: Select high performance network programming I/O model under high concurrency.

  2. Select an appropriate RPC serialization mode: Select an appropriate serialization mode to improve packet and unpacket performance.

However, when I interviewed candidates, I found that although some students had made preparations, they could only tell the general process of individual RPC framework and could not deeply understand the working principle of each link. Therefore, the overall impression to me was that the application level was passed, but the principle was not deep enough.

And I asked for you is: for middleware technologies such as tools and frameworks, although in practice is not recommended to repeat the wheel, but in an interview to prove your ability to have made the wheels, because want to evaluate whether a programmer to technology stacks have comprehensive understanding, inspects its ability to build the wheels is a good place to start.

So, in an RPC interview question, how do you prove that you’re good at building wheels? Look at the next chapter.


Welcome to the Java universe (wechat id: Javagogo)