Could you please tell me what the whole process looks like after entering the Baidu URL?

2021.07.30

First of all, when we enter https://www.baidu.com in the browser, what we want is to find Baidu's server to request data, so where to find Baidu's server address?


Hello everyone, I am Afan. Although the golden three and the silver four have passed, but the golden nine and the silver ten are coming soon. As a fan who is prepared for danger in times of peace, she is always preparing to study and interview. Today, I believe that many interviewees have been asked about this topic, but the question is actually not. Difficult, but if some friends have not encountered it, they may not think about the specific details, or they may know many things but do not know where the interviewer asks this question, so they will be owed to think about it. Not the point. Let's take a look at what happened in the whole process in turn.

 

Let's first think about what processes will be involved in the whole process:

  • DNS
  • establish connection
  • send request
  • Response data
  • Render the page

First of all, when we enter https://www.baidu.com in the browser, what we want is to find Baidu's server to request data, then where to find Baidu's server address? The request server must know the server's ip Address, domain name address alone is not enough. At this time, what we think of is that we need to find the ip address of the server based on the domain name, so there will be a DNS resolution process. The entire DNS resolution process is also very complicated, involving the layer-by-layer search process of DNS, as well as the entire complex DNS load and resolution. In the interview process, if you have a deeper understanding of DNS, you can expand it. If you don’t understand, just take it with you. Don’t dig for yourself.

Here we assume that the IP address of a Baidu server obtained after DNS resolution and various load balancing is 1.2.3.4, then when the IP address is obtained, according to the web service standards, we also know that the default port is 80, if it is not the default port If it is, the address will be carried, so the browser can establish a connection with the server at this time. I believe everyone knows that the process of establishing a connection is a TCP three-way handshake.

 

Regarding the process of establishing a TCP connection, there is an article introduced in the front of the official account, and interested friends can search for it. I have to say here that TCP’s three handshake and four wave of hands are also very important knowledge points in the interview process. A fan often encounters this problem throughout his career, whether it is an interview or an interview with others, and it is not about this. How many questions test people, mainly because I want to see if the basic skills are solid.

When the connection is established, the client and the server will interact. The current Internet services are based on HTTP, so at this time the client will initiate an HTTP request, and each request will carry related request parameters to ensure that the server can Return the correct data according to the relevant parameters. The request will reach our application through the network, regardless of whether there is Nginx or other load in the middle, it will eventually reach the entrance of our application.

At this time, if the application is based on SpringMVC, then you can also talk about the flow of SpringMVC's front controller, processor mapper, processor adapter, processor Handler, and view resolver. That said, don’t say it if you are unfamiliar. Just take it.

When the server obtains the corresponding data according to the client's request information, it will return a response message, carrying the status code and related data to the front end. After the current end obtains the data, the entire page will be rendered. The rendering of the entire front-end page will be done after a while. As a back-end programmer, the interviewer should not ask about the details of the rendering. If asked, it would be embarrassing.

In fact, this topic can have many extended issues, such as the three-way handshake and four waved hands of the TCP connection with the DNS resolution process mentioned above. You can also extend the difference between the HTTP protocol and the HTTPS protocol and the seven aspects of the network. What is the layer structure? Then you can ask about Nginx and load balancing. By the way, if your project is load balancing, how do you control traffic distribution and expand capacity and disaster tolerance in high concurrency scenarios.

Generally speaking, as a programmer, there is still a lot to learn, and in the interview process, we have to use our strengths and avoid weaknesses, try to talk to the places we are familiar with, and try not to mention the places that we are not familiar with. If you are really asked to know Just know if you don't know or don't know, honestly confess with the interviewer, don't try to get through, you must know that the interviewer is not stupid.

Well, today I shared an interview question with you, I hope it will be helpful to you, more content about our future articles, continue to share with you.