10 methods Improve ASP.Net application performance

Now write a asp.net the web application becomes very simple, many programmers are reluctant to spend the time to build a good performance of the application. This paper will be discussed ways to enhance web application performance of 10 methods. I will not limited to only discuss the contents of asp.net applications, web application because they are only a subset of procedures. This article can not provide a complete web application performance improve the guidelines, which would require a book length. This article only provides a web application performance enhancing the good start. (What's left is our own research has slowly).

In this work, I often to rock climbing, rock climbing in each, I will review the climbing route map and look at the success of rock climbing in front of the proposal. Because we need their successful experiences. Similarly, when you have a need to revise the procedures or performance problems is to develop a high-performance site, you also need to learn how to write a kind of high-performance web applications.

My personal experience comes mainly from the asp.net Group at Microsoft as program manager, operation and www.asp.net website, and assist the development of Community Server (it is asp.net Forums,. Text, and nGallery integrated software upgrade ). I think these experiences so that I can to help you.

You may think your application is divided into different logic. You may have heard the three-tier structure of physical or N-tier structure, which is the most common framework, the different procedures of physical function assigned to the various hardware to implement. In this way, if we want to improve the performance of the applications, plus some hardware can achieve the objective. Normally this method can increase application performance, but we should avoid the use of such methods. Therefore, as long as possible, we should asp.net pages and put it to use the components of an application to run.

Distributed because of the deployment, use the web services or Remoting, it will enable the application's performance dropped 20 percent or more.

The data layer a bit different, it is best to deploy independent, with a separate hardware to run it. Although this, but the database is still application performance bottlenecks. Therefore, when you want to optimize the process when you first think of places should be optimized on the data layers.

In the application to amend the emergence of problem areas before, you have to confirm the problem of the procedure looks very tight, Performance Analyzer to find applications where spent more time very useful. We use these places is less than the intuitive feeling.

In this paper, two types of performance optimization: a big performance optimization (big optimizations), such as the asp.net Cache; another kind of performance optimization is a small (tiny optimizations). Sometimes small optimize the performance of very useful. You only to your code for a small change to, and then call it a 1,000 or 10,000. For a big performance optimization, you will in your application's speed will be a big upgrade. To optimize the performance of a small, perhaps every request for a microsecond can only improve, but if every day at the request of the great, then applications are very significant improvement in performance.

The performance of data When you want to optimize the performance of an application when you can use the following order: your code to access the database » If so, how kind frequency access the database » Similarly, this test method can also be used in the use of web services or Remoting procedure code. This article will not discuss the use of Web services and Remoting process optimization problem.

If you have a section of the code to access the database at the request of and in other places you can see to achieve the same function of the code, then you must optimize it. Continue to revise and perfect the test, unless you have a very large performance problems, your time spent on optimizing for the best, connecting to the database, to return to the size of data sets, and a query to return on time.

According to a summary of experience, let us take a look at 10 can help you improve your application performance experience, I will enhance the efficiency of their small number Congtaidaoxiao that followed.

First, to return to a number of data sets Check your database access code to see if there are a number of requests to return. Each from the lower your application to respond to requests per second the number of times. Through a single database request to return multiple result sets, and the database can reduce the communication time, so that your system is scalable, can also reduce the database server to respond to requests workload.

If you are using dynamic SQL statement to the return of multiple data sets, then I suggest you use stored procedures to replace the dynamic SQL statement. Whether or not to write business logic stored in the course of this somewhat controversial. But I think, to write business logic can be stored inside the process to return result sets restrictions on the size, reduce the flow of network data, in the logic of the data also do not have to filter in, this is a good thing.

SqlCommand object with the ExecuteReader method returns a strong type of business object and then call NextResult method to move data sets guidelines to target data sets. Examples of a demonstration of a return to multiple-type ArrayList object example. Only to return from the database you need the data you can greatly decrease the amount of memory by the server.

Second, the data page ASP. NET DataGrid's a very useful feature: tabbed. If the DataGrid allow paging, in a moment only to download a page of data, In addition, it has a data page of the economy tabled in navigation bar, it allows you to choose a browser page, but each time only to download a Data.

But it is a small drawback is that you have to put all the data are bound to the DataGrid. In other words, you must return to the data of all the data and then DataGrid to filter the light of the current page by page to the current needs of the data show. If there is a record of 10,000 set of results for use DataGrid page, assuming DataGrid show only 25 per page of data, it would mean that each request has to 9975 data are discarded. Each request must be returned to such a large data sets, the impact of application performance is very great.

A good solution is to write a page of the storage process, for example 2 is a table of the Northwind database orders of the paging storage process. You only need an current page, each page shows the number of two parameters into the storage process will return to the corresponding results.

The server side, I wrote a special page to handle the control of the data page, where I used the first method, in a store inside the process to return to the results of two sets: the total number of data records the results and requirements Set.

Back to the records to be implemented depends on the total number of enquiries, for example, where a return to conditions may limit the size of the result set. In tabbed interface must be based on data sets records to calculate the size of the total number of pages, so the results must be returned to the set several records. For example, if a total of 1 million records, if the conditions where you can filter into 1000 only to return to record, store paging logic of the process should be returned to those who need to know the data displayed.

Third, the connection pool TCP used to connect your applications and databases is an expensive things (very time-consuming things), Microsoft developers can use the connection pool to repeated use of database connections. Compared to every request to use the TCP with a database connection pool not only in the existence of an effective link when a new TCP connection. When the time to close a connection, it will be into the pool, it will still maintain the link with the database, so that the database can be reduced and the number of TCP connection.

Of course, you have to pay attention to those who forget the Commissioner of the connection, you should run out every time it shut down immediately after the connection. I want to emphasize is: no matter what people say. Net framework in the GC (garbage collection) will run out in your target after connecting link called targeted Close or Dispose method you close the explicit connection. Do not expect CLR will be in your imagination time to switch off their connections, although the CLR to the final destruction of objects and close-to, but we can not identify it in the end will be what to do when these things.

Optimal use connection pool, there are two rules: First, open access, data processing, and then close the connection. If you must be repeated each time the request to open or close the connection, it has been better than an open-access, and then it was transmitted in various ways. Second, using the same connection string (or use the same user ID, when you use the time integrated authentication). If you do not use the same connection string, if you log on to the user's connection string, this will not be able to use the connection pool optimization feature. If you use the integration of proof, because many users, so you can not take full advantage of the connection pool optimization feature. . NET CLR provides a performance counter data, which we need to track performance characteristics of the time very useful, of course, including the tracking of the connection pool.

No matter what your application in time to even another machine resources, such as databases, you should focus on optimizing resources you even the time spent, receive and send data, and to return to the number of times between. Optimizing your application in the treatment of each point (process hop), it is to improve the performance of your application point of departure.

The application layer contains data link layer, the transmission of data to the appropriate type of case handling and business logic. For example, in the Community Server, it is necessary to assemble a collection of Forums or Threads, and application business logic, if authorized, but more importantly, here to complete the cache logic.

4, ASP. NET API cache Before writing applications, you need to do first thing is to allow applications to maximize the use of the ASP.NET cache function.

If your component is to Asp.net applications to run, you just System.Web.dll applied to your project in it. HttpRuntime.Cache property can then use the visit to Cache (You can also visit Page.Cache or HttpContext.Cache).

There are a few rules of the data cache. First, the data may be used frequently, such data can be cached. Second, the data is very high frequency of visits, or a data access frequency is not high, but its very long life cycle, so the best data cache also up. The third is an often overlooked issue, sometimes we had too many data cache, usually in one of the X86 machine, if you want to cache data 800 M, it would appear memory overflow error. So cache is limited. In other words were said, you should estimate the size of the cache set, the cache size limit set in less than 10, otherwise it may be the problem. In Asp.net, if too large cache of memory overflow error will be reported, especially if the cache when the DataSet object.

Here are some you must understand the importance of the cache mechanism. First, the cache to achieve the "last used" principle (a least-recently-used algorithm), less the time when the cache, it will automatically force the removal of those useless cache. This was followed by "conditions rely on" the principle of forced removals (expiration dependencies), conditions can be time, keywords and documents. To time as the conditions are the most commonly used. In asp.net2.0 a stronger increase in the condition that the database conditions. When the data in the database changes, will be forced to clear your cache. To a better understanding of the conditions rely on the database see Dino Esposito MSDN magazine in July 2004 Journal of the Cutting Edge column. Asp.net cache structure as shown below:

5, pre-request cache In front, I mentioned that even though we have only to certain places made a small performance improvement can also get big improvement in performance, I very much like to use pre-cache request to question


View:(632)    comments:(0)
Nickname:
comments:


About esoftwarefactory.com |Sitemap |Newletter |Tags |Advertise
Partners: best dvd copy software
Copyright ©2008 Freeware shareware downloads - esoftwarefactory.com, All Rights Reserved