Performance Tuning overview of high-performance ASP. NET site construction (1)

Source: Internet
Author: User
Tags website performance

High-performance ASP. NET Site build series Article Directories

During this time, I reorganized the series of articles, and the previous introduction to performance optimization was not very clear. It can be said that starting from this article, it is the beginning of a complete series.

The topics in this chapter are as follows:

General performance tuning process

Analyze page loading information using analysis tools

Analyze performance bottlenecks using analysis tools

General performance tuning process

Before solving the performance problem, you must first confirm the problem. First, let's take a look at the general process of ensuring high performance:

1. Continuous Monitoring

2. Set performance goals

3. Continuous Improvement

1. Continuous Monitoring

The website performance is generally affected by two factors:

I. What we can control, such as code;

2. What we cannot control, such as the number of users to access or the server itself

In particular, as the site's access volume increases, there may be no problems in the past. Now, the problems to be solved at different stages are also different. Therefore, it is necessary to continuously monitor the website and find out the reasons for the slow speed of the website as early as possible. Later in this article, the Department will introduce some monitoring services that we can use to help us do these things.

2. Set performance goals

The most intuitive feeling of website performance is the loading time of pages after the website is opened, which is also the most direct experience of visitors. A lot of optimization work, whether it is optimization at the front end or optimization at the backend, is to allow users to see the pages and information they want to see more quickly. This is often the purpose of our subsequent discussions.

First, you must understand the meaning of "fast": How fast is a website's response speed "? It takes a lot of time and effort to optimize the website. If the website itself is already very fast, for example, the time when the webpage is displayed to the user is millisecond-level, we can indeed spend more time making it faster, but the cost will be higher!

3. Continuous Improvement

There are a lot of things involved in performance optimization, so we must confirm that the optimization measures have indeed improved the performance of the site. To achieve this purpose, there are several rules to follow:

1. Only one change is allowed for each optimization. If there are many changes, these changes may affect each other and finally lead to some strange phenomena. Sometimes these "optimization measures" have reduced the website performance. In addition, if one change is made multiple times, it is not conducive to measuring that the "optimization measures" are truly improving the performance of the website.

2. Continuous testing. After each so-called "optimization", you must test whether the "optimization" has actually improved the performance. If it has not been improved, roll back the operation.

The general optimization steps are as follows:

1. Record the performance index and related data of the current website (we will tell you how to obtain the performance index data later)

2. diagnose the performance fault point of the site. The performance of the site may be affected in several places. However, at this time, we only choose the one with the greatest impact for optimization.

3. Solve the identified performance fault point.

4. Test. Collect data and compare it with before optimization to see if it improves performance.

5. Repeat steps 1 to 4.

Although some rules have been proposed above, we can flexibly handle certain situations: when we look for problems that affect performance, we find multiple problems, and these problems will affect performance based on our experience, so we can modify them at the same time.

We use a flowchart to summarize the above optimization steps. As follows:

The following describes how to use some simple tools to analyze some data related to the site performance. In the previous article, we discussed the general process of performance tuning, this article introduces some methods and tools to help you get started quickly.

The topics are as follows:

General performance tuning process

Analyze page loading information using analysis tools

Analyze performance bottlenecks using analysis tools

Analyze and load page information using analysis tools

After all, the optimization of the site is the optimization of every page of the site, even if the page of the site is displayed to the user's eyes faster. So before that, let's take a look at the components of a web page:

1. Html file: in ASP. NET, Html files are usually generated by parsing the. aspx page. This parsing process is performed on the server and consumes most of the server's resources.

2. Images and flash files: A website usually contains many such files.

3. Js and css files: these files can prevent page rendering.

After understanding the components of the page, we can classify the factors that slow the page loading into the following categories:

1. The server spends a lot of time parsing. aspx, that is to say, there are many reasons for this problem because the server generates html text too long. For example, the database query is slow, which affects page generation ).

2. It takes a lot of time to pass html text between the server and the browser, for example, the Viewstate in the page is large and the network is slow ).

3. It takes a lot of time to load images and flash files.

4. Loading Js and css takes a lot of time.

To make the loading of a page faster, we need to know which of the above processes affects the speed (this series of subsequent articles will be detailed ). Once we know that this type of problem causes performance problems, we can take the right remedy.

Next we will use some tools to simply view and analyze the performance of the site, so that you can quickly learn how to perform simple performance analysis.

The waterfall chart is used to analyze the loading time of each part of the page. For example, the analysis graph part loaded on the homepage of the blog garden is shown below ).

We can know the loading time of each file through the "timeline" in the figure. The longer the timeline, the longer the file will be loaded.

After reading the above figure, you should be very curious about how the above figure is generated. The following describes some tools for generating a page to load a waterfall chart.

Let's first take a look: Firefox + Firebug

Firefox: http://www.mozilla.com/en-US/firefox/

Firebug: http://getfirebug.com/

The following describes how to generate a waterfall map for page loading. If you are familiar with this process, you can skip this section)

1. Open Firefox and press F12 to see the following picture:

2. In Firebug, select "enable" in the select "network" drop-down box ".

OK. Let's take a detailed look at some data and the meaning of the illustration in the waterfall diagram.

1. Request and Response Information

In the waterfall chart, click "+" for each row as follows:

After the symbol is expanded, we can see all the request and response headers, as shown below:

2.Timeline Information

When we move the mouse over the colored timeline bar, we can see the detailed information of the time spent requesting the file, as shown below:

We use a table to describe the meaning of each time period:

Domain name resolution

Time taken to find the IP address of the server where the requested file is located

Establish a connection

Time taken to open the TCP link from the client to the server

Send request

The time taken by the browser to send the request. It may be a bit strange: Why is the request still waiting? Didn't the request be sent when the connection is opened?

In fact, the browser will put the request for the file to be requested in the Request queue, the queue length is generally limited, if the page needs to request a lot of files, if the maximum number of queues is reached, subsequent file requests will wait.

Wait for response

The time taken by the client to send a request until the first byte of the server is accepted.

Accept data

Time taken to accept the entire request file or data

'Domainloaded'Event

The time it takes to start DNS addressing from the request to download the DOM of the entire page. Note: At this time, the skeleton of the page is downloaded, and some resources, such as images and js, are not downloaded. After the DOM of the page is downloaded, the user can see the page, but some resources are still being downloaded.

'Load' event

The time it takes to download DNS addressing from the request to the entire page, including all resources.

3. Page-level request information

That is, some summary information of the requests on the whole page.


Related Article

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.