Web site Performance Optimization Solution

Source: Internet
Author: User
Tags base64 encode scalar throw exception time 0
First, performance parameters:1, throughput 2, Response time 3, Execution time 4, scalability second, the Performance optimization program:
number Programme Description State
1 When you deploy your application, you should turn off debug mode, which will effectively improve application performance (Web.config file Debug=false)    
2 When you deploy an application, you use release mode to compile the publication, optimizing the program resources.    
3 try to avoid using throw Exception, reduce additional overhead   provide users with a friendly error page protected void Application_erro R (Object sender, EventArgs e) {     ....          & nbsp;    application["Error" = error;               Response.Redirect ("myerrorpage.aspx"); Because of the caught exception, performance is not elevated, but provides a unified, friendly error message page
4 Page-level caching of the appropriate dynamic pages <%@ OutputCache duration= varybyparam= "*"%> to improve access speed.       Two cases: 1. Different versions of the cache are 2, depending on the parameters. Different versions of the cache, depending on the URL, for example : http://010.52tong.com http://021.52tong.com aspx page: <%@ OutputCache duration= varybyparam= "id" varybycustom= "Ceshi"%> Global.asax: public override Str ing getvarybycustomstring (HttpContext context, string arg) {if (arg = = "Ceshi") {string s_cs=request.          Url.tostring ();      return Request.Url.ToString (); Return to base. GetVaryByCustomString (context, ARG); }
5 Use stored procedures as much as possible to complete data operations    
6 For read-only data access, use Datereader instead of a dataset    
7 Turn off unnecessary ViewState. When using ViewState, each object must be serialized into the ViewState and then deserialized by a postback, so the use of ViewState is not without cost. <input type= "Hidden" is not encrypted, ViewState only Base64 encode each control (on the tag) <asp:datagrid enableviewstate= "false"?/> Each page (in the Directive) <%@ page enableviewstate= "false"?%> each application (in Web.config) <pages enableviewstate= "false"?/>    
8 Adjusting database SQL statements Prerequisite: The need to fully understand the business logic
9 Adjust Index
                small test to illustrate the importance of indexing, although the execution time only from 3 milliseconds to 0 milliseconds, but only for the test environment of single users, When tens of thousands of users concurrent operations, resulting in fierce server resource competition (memory io/disk IO/CPU context switch), CPU execution time should be at a geometric level of speed growth.   SELECT COUNT (*) from dbo. Public transport--12120 PEN record  /*------currently no index status        table Scan full table Scan        logic read 256 times         Execution time 3 ms-------/Set Showplan_all on the Go select * FROM dbo. Bus where city= ' Xuancheng ' Go Set showplan_all out go   |--select * FROM dbo. Bus where CI ty= ' Xuancheng '  |--compute Scalar (DEFINE: [Bus].[ Linestop]=[bus]. [Linestop])      |--table Scan (OBJECT: ([cq20].[ DBO]. [bus]), Where: ([bus]. [City]=convert ([@1]))   SET STATISTICS IO on go select * FROM dbo. Bus where city= ' Xuancheng ' Go Set statistics io out go &nb Sp Table ' Bus '. Scan count 1, logical read 256 times, physics read 0 times, pre-read 0 times.   SET STATISTICS TIME on the go select * FROM dbo. Bus where city= ' Xuancheng ' Go Set statistics timing off go   SQL Server execution times :    CPU Time = 0 milliseconds, time consuming = 3 milliseconds. /*-----------------Create the index of the City field-------------------*/Create  index [idx_city] on [dbo]. Bus ([city])    /*------status after Indexing        Index seek index scan     & nbsp;  logic reads 9 times        Execution time 0 milliseconds-------/SET SHOWPLAN_ALL on Go select * FROM dbo. Bus W ITH (index=idx_city) where city= ' Xuancheng ' Go Set showplan_all off go   |--select * FROM dbo. Bus with (index=idx_city) where C ity= ' Xuancheng '        |--compute Scalar (DEFINE: ([Bus].[ Linestop]=[bus]. [Linestop])        |--bookmark Lookup (Bookmark: ([Bmk1000]), OBJECT: ([CQ20]. [dbo]. [Bus]))             |--index Seek (OBJECT: ([cq20].[ DBO]. [Bus]. [Idx_city]), Seek: ([bus]. [city]= ' Xuancheng ') ORDERED FORWARD)   SET STATISTICS IO on go select * FROM dbo. Bus with (index=idx_city) where city= ' Xuancheng ' Go Set STATISTICS IO off go   table ' bus '. Scan count 1, logical read 9 times, physicsRead it 0 times and read it 0 times in advance.   SQL Server Execution time:    CPU time = 0 ms, Time consuming = 0 milliseconds.  

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.