[Website Performance 2]asp.net platform under the site performance tuning of the actual combat program

Source: Internet
Author: User
Tags connection pooling jquery library website performance

Article Source: http://www.cnblogs.com/dingjie08/archive/2009/11/10/1599929.html

Objective
Recently help friends to run the platform for Performance tuning, the effect is good, so write it out together to exchange. If the article has you feel wrong, or do not understand, please add QQ Group: 4656272, Welcome to correct and discuss together. (PS: Vulgar Humanities pen is poor, crossing please more magnanimous)

Background
Friend's platform website belongs to the vertical type of information community website, originally developed with ASP. NET 1.0, later upgraded to ASP. NET 2.0, the database is SQL SERVER 2000, the operating system is Windows 2003 server, two servers, a Web server, A single database server. There are currently about 80 tens of thousands of user accounts, with 30多万条 articles and more than 200 W posts. As the volume of data increases, the load becomes larger, often inaccessible, access error, or slow access.

Solve
Because it is already in production, the premise of performance tuning is that it does not affect existing business operations, can be deployed seamlessly, and can be quickly rolled back if problems occur. So I'm going to do the tuning several times so that it's a more secure performance boost without compromising normal business operations.

First step running environment tuning
This step is important, in a healthy and stable environment, in order to maximize the performance of the platform, so first to provide a healthy and stable environment for the platform.
1 ASP. NET Environment tuning
The tuning method described in "net Performance and Scalability Secrets" has been discussed with developers to reduce some of the unnecessary module in ASP, and to optimize some configuration files.

2 IIS Environment tuning
Reduces unnecessary ISAPI loading in IIS, streamlines the format of the IIS access log, sets the content expiration of files in IIS for picture files, javascript,css and so on, and enables the Gzip compression feature of IIS, by http:// support.microsoft.com/kb/922703/(link valid) This article has done an etag setting to improve the performance of HTTP requests and to set tuning for the application pool of IIS according to the actual situation.

3 SQL Server Tuning
Upgrade SQL Server 2000 to SQL Server 2005, set it up as described in "Tuning SQL Server 2000 Settings" (invalid link), and modify the memory footprint. My advice: If you are a separate database server, make SQL Server occupy the most memory possible.
After the first step of tuning, performance has improved, reflected in the lack of access or access to errors in the situation decreased. So start the second step.

Second step collects data to find platform performance weaknesses
Based on the IIS access log, I did a 24-hour sample. Found 10 of the most visited pages and 10 pages with a longer response time. Optimized SQL Server database system based on MSDN application Profilerhttp://www.microsoft.com/china/msdn/library/data/sqlserver/Profiler.mspx ? mfr=true (link valid) The method described, find the 10 most executed SQL statements and the execution time of a long SQL statement. provided to the developer and the recommendations are optimized.
(i) Front-end optimization
The most visited pages are the final page of the article and the final page of the post, when I sacrifice the best client debugging tool known to Firebug, as described in the Firebug full-text-firebug (invalid link) and the 34 website acceleration Method (link invalid) to optimize. The main include:
A) The final page is reconstructed with DIV+CSS, and a reasonable expiration date is set to speed up the client download and the rendering and rendering of the browser Dom engine.
b) because the platform uses the jquery library, directly refer to the JS file on Google, reduce the number of bytes transferred and connections, improve access speed.
c) JS and CSS compression, and picture animation files placed under a separate domain name, such as http://images.xxx.com, because the old browser for a domain name limit of 2 concurrent connections, using this method can be resolved, pay attention to this domain name set the validity period.
d) Turn off unnecessary viewstate in ASP. NET and reduce transmission bytes.

(ii) Platform system optimization
With a maximum of 10 SQL statements and a long execution time of SQL statements found, many are due to the article page final page and post final page update visits caused by similar updates, initially want to add a server to do the image distribution of SQL Server, insert, UPDATE, delete all on one platform operation, Another machine can only do query operations.

However, this increased server can only be a database server, and changes on the system is relatively large, not the best scenario. After consideration, since it is updated data operation does not need real-time, then add a server with CentOS 5.x, install memcached, do incremental updates, and that server remaining resources can do other things, the realization of the idea is to first update to memcached, If you find that the number of updates reaches a threshold, update to the database at once. Platform member online status, from the database also changed to the memcached.

To improve the performance of the DAO layer, I recommend that their development use nhibernate, a mature database application framework, using database connection pooling to improve the reusability of database connections.

Where the execution time is longer SQL statement because of the fuzzy query caused by the increase of the server is again used, on the above loaded with Lucene, the database needs to query the data, submitted to Lucene, search all put into Lucene to do, the specific here does not trace back, Interested can find the relevant information here (invalid link).

After the second step, the performance is improved to a new stage. Inaccessible, access errors or slow access are rare.
But the optimization is endless, and the current situation is only suitable for the current access situation, and so on the number of visits to now several times, there will be problems, so I am ready to optimize the next step.

Third-Step architecture optimization
Here, I will be on the new server again, installed a squid cache server, after tuning to improve the load capacity again, and installed in front of the squid, nginx full use of Nginx Epoll features, and put the previous set of HTTP/ images.xxx.com/ move to Nginx below. One of the nginx,squid,memcached installation configuration process will not repeat, (link invalid) There are many, also can add QQ Group: 4656272, to discuss.

Other
In the process of analyzing the log, it is found that many visits are caused by spiders of the search engine, and because the end page of this platform is not static, it causes a lot of unnecessary database connection. I have taken the following methods:
1 Reasonable settings robots.txt, for unknown or unwelcome spiders, rewrite directly to a static page in Nginx based on its agent.
2 generates a static page to generate HTML based on the request.

At this point the performance of this platform has been significantly improved, inaccessible, access errors or slow access to the situation no longer appear

[Website Performance 2]asp.net platform under the site performance tuning of the actual combat program

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.