Monday, November 1, 2010

ASP.NET applications, optimizing the performance of 26 everyday tips

The second Internet Guide: consuming server resources. ASP.NET application pooling to help application (Connection Pool) to open and close the database to improve performance results. The system will connect the user's database connection pool on demand when removed, off when the recovery of connection, wait for the next connection request. Connection pool size is limited, if the connection pool to create a connection is still required after the maximum, be greatly effect performance. Therefore, to establish a database connection only open the connection when the real needs of operation, the application immediately after the close, so ... Body:
 
1. Visit Performance Optimization
Database connection and close
Resource requirements for visitors to create a database connection, open connection and close the connection of several operations. This part of the process needs to exchange messages with the database repeatedly authenticated, expensive trial of strength. . NET application application to help the connection pool (Connection Pool) to open and close the database to improve performance results. Database connection on a user's connection pool, the demand out, close the connection when the back, waiting for the next connection request.
Connection pool size is limited, if the connection pool to create a connection is still required after the maximum, be greatly effect performance. Therefore, to establish a database connection only open the connection when the real needs of operation, the application immediately after the close, so try to decrease the time to open the database connection to avoid connection beyond the control of the situation.
Application of the stored procedure
A stored procedure is stored on the server a set of pre-compiled SQL database statement, similar to DOS batch of documents. Stored procedure with an immediate visit to the database functions, message processing is very fast. Application of the stored procedure did not result to avoid multiple compilation command, after running an operation plan to reside in its cache, the demand just after the call directly to the binary cache.
In addition, the stored procedure runs on the server side, independent of the application ASP.NET applications, easy to correct, the most important achievement is that it did not decrease database operation statement on the Internet transmission.
Query optimization
ADO Connection ASP.NET application applications considerable consumption of resources, SQL database statement runs longer, taking longer time resources. Therefore, as far as possible applications optimized SQL database statement to decrease run time. For example, the query does not contain sub-queries, take advantage of indexes.
 
2. Char string operations performance optimization
Application tips ToString value category Char string in the connection, the frequent application of the "+" directly to the number added to the char string. This trick is simple, the results did not get the correct results, but not the same as it relates to the type of data, digital demand through the packing operation into the reference category was not added to the char string results. However, a larger effect on performance packing operations, due to the cessation of such treatment, will be allocated in the managed heap of a new object, the original value to the newly created objects.

Application of value types do not result ToString tips to avoid packing operation, thus increasing the practical application of program performance. The use of StringBuilder class String class objects are immutable, the String object re-assigned value, in essence, is to re-create a new value of the given String object and the object, the performance of their tricks ToString is not very significant increase. In dealing with char strings, the best use of StringBuilder class, the. NET application application namespace is System.Text. This class does not create new objects, but after Append, Rearouse, Insert and other tricks to stop directly on the char string operations, results of operations after return ToString tips. Its definition and operation of statement is as follows:
 
3. Optimize Web servers and the practical application of program-specific configuration files to meet your specific needs
By default, ASP.NET applications enabled application configuration is set to feature the most extensive and try to adapt to most everyday knowledge of the program. Therefore, the actual use of programs we did not score DEV procedures based on the actual use of application functionality, optimization and change some of these configurations to increase the actual use of program performance. The following list is a part of you should plan options.

The practical application of procedures only need to enable authentication. By default, the authentication mode to win the interface, or integrated NTLM. In most cases, the demand for the practical application of the authentication process, the best documentation in Machine.config disable authentication and enable authentication in the Web.config document. Under the appropriate request and response encoding settings to configure the practical application of procedures. ASP.NET Application Application default encoding format is UTF-8. If your program is strictly practical use ASCII, you configure the application procedures for the practical application of the performance of ASCII to get a little bit higher.

On the practical application of planning applications to disable AutoEventWireup. In Machine.config document will AutoEventWireup attribute is set to false, meaning PAGE names and events not to stop the match tips on matching and linking the two (such as Page_Load). If PAGEDEV we want to apply this part of the event, demand in the base class override this part of the trick (for example, demand for the load event rewrite PAGE Page.OnLoad, rather than as applied Page_Load tips). If disable AutoEventWireup, PAGE will be left after PAGE of the event and not connecting automatically as it is, get a slight performance boost.
Removed from the request processing pipeline without the module. By default, the server computer Machine.config document Nodes are reserved for the activation of all functions. The use of procedures based on the actual application, you do not score from the request to remove unused modules pipeline to get a little performance boost. Check each module and its functionality and customize it to your needs. For example, if you are not in the actual application of the use of the dialogue process state and output caching, you do not score from the List, remove them so that requests do not run more meaningful processing, do not have to run each module to enter and leave the source code.
 
4. Sure you want to disable debug mode
Practical application in the deployment of the production process or to stop before any performance measure, always remember to disable debug mode. If debug mode is enabled, the actual use of the program's performance estimates are subject to extraordinary large effect.
 
5. Extensive reliance on external resources for the practical application process, please plan on multiprocessor computers enabled Internet Gardening Application ASP.NET process model helps enable applications on multiprocessor computers scalability, multiple processes will be distributed to workers (each one), and each process is to contact the processor set to its CPU. This performance is called the Internet gardening. If the application of the practical application of program called a slow database server or external dependencies with COM objects (there is only mention of the two estimates), compared with the practical application of procedures for opening your Internet gardening is beneficial. However, in determining the opening of the Internet gardening, you should test the practical application programs on the Internet operation of the park.

No comments:

Post a Comment