Building high-performance asp.net sites

Source: Internet
Author: User

Building a high-performance asp.net site profiling the process of the page (front end)

Foreword: When ASP.net website optimizes, often not just know asp.net is enough. In the process of optimization, it is generally first to find out where the problem may exist, and then prove that the problem is to solve the problem, after confirmation, in some measures. The structure of a series of articles is this: first, the tuning of the front end, I will be in the article after the title "front", if the background code tuning, I will be labeled on the title "Back End", if the database design tuning, I will be labeled on the title "Database", I hope that we have a lot to suggest.

The main analysis of the process, so that everyone has a comprehensive understanding, the next chapter began to analyze the step-by-step.

The topics in this article are as follows:

Parse the parsing process of a page

Analysis of possible optimization points

Parse the parsing process of a page

The parsing process of the page, this is not the process that we often say the life cycle of the ASP.net page, and the browser requests a page, and then the browser renders the page process.

In this article, I will first explain the page parsing process, showing the overall description, and then at each point to propose optimization methods. First whole, after local.

When the browser requests a Web page to start from a URL. The following is the process description:

1. Enter the URL address or click on a link to the URL

2. The browser according to the URL address, combined with DNS, resolve the URL corresponding IP address

3. Send HTTP request

4. Start the server that connects the request and request the relevant content (as to how the request is handled, we do not discuss here for the time being, just the issues to be discussed in the following article)

5. The browser resolves the content returned from the server side and makes the page appear, while also continuing with other requests.

The above is basically a page is requested to the reality of the process. Here we begin to dissect the process.

When the URL is entered, the browser will know what the IP is, only the IP address, the browser can be prepared to send the request to the specified server specific IP and port number above.

The browser's DNS parser is responsible for resolving the URL to the correct IP address. This parsing work takes time, and in this parse time period, the browser is not able to download from the server to anything. But this parsing process can be optimized. Just think, if each browser request a URL every time need to parse, then each request has a little time consumption, may this time consumption is very short, but the performance of the promotion is a little bit of "tune" out. If you cache the corresponding URL and IP address, then when the same URL is requested again, the browser does not have to parse, but read the cache directly, which is bound to be faster.

In fact, the browser and control system is provided with such support.

When the IP address is obtained, the browser sends an HTTP request to the server, and below we look at how the send request is sent:

1. The browser requests the server to open the connection by sending a TCP packet

2. The server also sends a packet to answer the client's browser, telling the browser that the connection is open.

3. The browser sends an HTTP GET request that contains a lot of things, such as our common cookies and other head header information.

In this way, a request is passed.

After the request is sent to the server, the server side of the program, for example, the browser clear file is a asp.net page, then the server side of the request through IIS to the ASP.net run, the last series of activities after the final result, of course, It is generally sent to the client in the form of HTML.

In fact, the first to reach the browser is the HTML documents, the so-called HTML documents, is the pure HTML code, does not contain any pictures, scripts, CSS and so on. Which is the HTML structure of the page. Because this is only the HTML structure of the page returned. This HTML document is sent to the browser for a short period of time, typically accounting for around 10% of the response time.

After this, then the basic skeleton of the page in the browser, the next step is the browser parsing the page process, that is, step-by-step from top to bottom parsing the skeleton of the HTML.

If you encounter an IMG tag in an HTML document at this point, the browser sends the HTTP request to the URL of the IMG response to get the picture and then renders it. If there are many pictures in the HTML document, Flash, then the browser will be a request, and then render.

Here, you may feel a bit slow in this way. It is true that the requested part of the resource file such as this picture can also be optimized. Not to say anything else, if each picture has to request, then the previous steps should be said: Parse the URL, open the TCP connection, and so on. Open connection is also to consume resources, just as we are in the database access, we are as much as possible to open the database connection, multiple connections in the pool. As such, TCP connections can also be reused. But reuse also has a problem: If two pictures their URL address is as follows:

  

  

  

  

  

  

  

  

  

  

The time required for these pictures is consumed as follows:

  

You first see the top of the yellow line, the Yellow line on behalf of the browser to open the connection, the second half of the Yellow Line is blue, which means that the browser requested HTML documents.

The top second blue line indicates that the first picture has been requested, and that the image is requested to use or a previous TCP connection.

You see the third line, the first part is yellow, the request for a second picture when a TCP connection opened, the latter part of the line is blue, indicating that the picture has been requested.

The rest of the pictures you want to request use the previous TCP connection.

Indeed, the TCP connection is fully used, but the picture download speed is really slow, from the figure, the picture is a sequential download down. The response time of the entire page is conceivable.

If you take the next approach, such as:

  

You can see that the connection is much, but the picture is almost all in parallel download down, compared to more quickly.

In fact, this is a trade-off problem.

In fact, the browser is also built in a number of optimization methods, such as caching pictures, scripts and so on. Or the way to download pictures in parallel, when it comes to parallel downloads, as shown above, it is bound to consume more connection resources.

Today, the main page of the process of the preliminary analysis, yes, we have a general grasp, the next one we began to gradually optimize, please pay attention to, but also hope that a lot of suggestions and feedback.

Copyright for the small Ocean and blog Park All, Welcome to reprint, reproduced please indicate the source to the author.

Article Source: Http://www.cnblogs.com/yanyangtian



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.