ASP.NET application performance optimization
1 Introduction
The main goal of performance optimization is to improve several indicators such as "concurrent users", "throughput", "reliability".
In essence, performance optimization should be multifaceted, to do "combination of point, by table and in the form". For example, from the point of view of the price, try to make a small amount of change, easy to implement; And scalability. It is not difficult to find that it is often difficult to do when trying some improvement methods.
Have a simple example:
In a business logic class, we have packaged some processing methods, with a method of functionality to find a node ID in the XML file already existing. Then let's naturally think about writing two methods:
XMLDocument LoadXml (String StrfileID) / / Load XML
Bool Checkidexisit (String StrfileID, String Strid) / / Determine if the node exists
Moreover, the method of loading XML can also be reused elsewhere; on the surface, there is no problem with the structure and function of this code. But when you run, if your logic is directly or indirectly called multiple times, you will find that the program is very slow. The reason is that the loading of the XML file is a time consumption, and the method of solving is simple, we provide several ways to:
BOOL CHECKIDEXISITBYXML (String strXml, string string) // determine if the node exists
Or Bool CheckidexisiBYXML (XMLDocument Objxml, String Strid) / / Determine if the node exists
In this way, we can achieve multiple borrowings through "one loading", and the efficiency is significantly improved. Therefore, in the design of the software structure, you should reuse the factors of "precious" data sources. (The "precious" data source here refers to the various objects or records that are obtained through complex processing or long calculations).
Performance optimization should be long-term because our work is always based on OS, Web Server, DB Server, Complier & Program Language, and so on. If you are familiar with .NET, Java, IIS, J2EE, you will find some features or API platforms, the other is not; so more time we need the transition solution, wait until the new version, we may Will discard the transition scenario direct configuration or easier implementation. [...]
2 demand articles
The first step in performance optimization is to see if the demand is reasonable, which is a back inspection of the project itself. In a sense, it is an escape principle. However, if this is a must from the perspective of software engineering, because the customer's needs are endless, and any software is a life period, and the OS is the application software. We always want users to display the farther and better to the business logic, but ignore a basic problem: the two will be connected, how to define the I / O relationship between the two, so that they can effectively cooperate with each other. It is very important to make user satisfaction.
Therefore, in performance optimization, the return inspection needs are to define the user interaction, making it more scientific. From the development of industry development, there is now a special person to study the user interaction, which is like the so-called "industrial design" in the traditional industry. It is increasingly valued!
When you return the demand demand, you will often "modify the demand", and you should combine the "demand definition personnel" and "developer" opinions, because each partner is different, must be used to make a long supply.
3 interactive response articles
The previously mentioned performance optimization can follow the order of "by the table", which mainly has two considerations:
First, this is something that the user can see directly, the effect is fast; second, the change is difficult to change the kernel than the cell.
Based on the B / S structure, there is a problem with the front desk (user) interacting with the background (Server), so the interaction response process actually includes two processes of "Background Calculation" and "Load to Client". It is clear that if we try to reduce the amount of data that needs to be downloaded to the client, it will reduce the response time.
According to the test, we found that the 40,000 records of records to the Grid are around 35s, and in fact, we will not display so many records at the page, and users will not see how much records at once. Usually we use paging methods, and so-called paging is only resinable. So, if we only bind the requested page, the amount of data to the client will drop. This is the idea that we propose "Computing all data, load local data" (as shown below).
Figure 3-1 "Instant Page Bind" Schematic
We will see another two questions from the perspective of the user. People who have used the ASP application will find that the ASP.NET application is highly refreshed high, and a small action is submitted to the server. From the perspective of software design, we feel very reasonable because there is no coupling and logical reuse. However, "fish is not part of the paw", we should still take a discordance. Go back to our system, we found that most pages are reread, re-bounding each operation when using the more frequent "increment-deleted-change" operation. So frequent refreshing, users will not recognize, and if the amount of data will affect the interaction time.
In fact, if the data is displayed in the Grid, then the deletion and modification do not need to re-load, and directly use the control itself, although it will be submitted but there is still a distinctive difference, the speed is also fast. More! For TreeView, "Increase - Delete - Change" does not need to be re-load because it does not need paging.
Another problem is that the user can understand, but it should still be given to the complicated and possible time consumption. This is not a scope of performance optimization, but it is an important UI norm, it is recommended to incorporate test requirements. There are two ways to display the progress bar:
1 The front desk shows waiting or completed the progress, the background processing is over, the front stage progress bar is closed, the processing results are displayed;
2 After submitting the task to the background, go to a waiting page, wait until the background is completed, go to the confirmation page. This way is usually based on XMLHttpRequest [13] technology, creates a separate computing thread in the background, which is that the client ends are not reflected in the first display method, and the progress bar is not moved.
4 deployment
Deployment is actually a big concept, covering software and hardware. Here we temporarily deploy system deployment structure, software settings, and hardware configurations into deployment. Regarding how to deploy a software system, you will not have explained here, only some specific practices are listed.
4.1 ASP.NET
When there is a large amount of data transmission, the exception of "Out of Memory" is often encountered. At this point, the value of the MemoryLimit property in the ProcessModel subkey in the machine.config file can be adjusted to make .NET can take advantage of more memory.
4.2 Others
4.2.1 Optimization Configuration Server & IIS
4.2.1.1 Expanding IIS Cache
The server retains some memory space as an IIS cache, stores objects for future request, so IIS can retrieve objects from the cache without retrieving from the hard disk. Adjusting the capacity of the IIS cache requires modifying the registry, the entry is as follows: hkey_local_machine / system / currentcontrolset / service / inetinfo / parameters / memoryCachesize = 0x 1e84800 (type REG_DWORD, Using Hexadecimal Notation.) Can also be set to decimal, range 0- 4GB, the default is 3072000 (3MB). Generally speaking, this value should be minimized to 10% of the server memory. IIS enhances the performance of the system through the value of the cache system handle, directory list, and other common data. This parameter indicates the memory size assigned to the cache. If this value is 0, it means "no cache". In this case, the performance of the system may decrease. If your server network communication is busy, there is enough memory space, you can consider increasing this value. It must be noted that after modifying the registry, you need to restart to make the new value take effect. 4.2.1.2 Adjusting IIS occupied CPU Time
The CPU processor capability of the server is always limited. Which application takes up the longest time of the processor, who can get the greatest improvement. (1) Double-click the system icon in the control panel of the NT. (2) Click Performance Tags. (3) Drag the cursor to None at the application performance, so that all the running services, including IIS, with the processor's time to maximum. (4) Select the total processing capability for maximizing the network application. Then click "OK."
4.2.1.3 Protocol and related optimization
(1) In order to improve performance and save resources, it should only run the required protocol. (2) The IIS server should be set to stand-alone servers, do not allow the server to withstand the extra load required by the domain controller. (3) You can distribute the NT server's page exchange files to multiple physical disks, pay attention to multiple "physical disks", which are ineffective on multiple partitions. Also, don't put the page swap file in the same partition as the Windows NT boot area. (4) Use disk mirroring or disk stripe sets to improve the read performance of the disk. (5) Regarding the log record, file records should be used instead of logging to the ODBC data source. In addition, it is also possible to increase the capacity of the memory buffer to record the log during recording to reduce the activity of the disk. The default capacity value of the buffer is 64KB. (6) It is best to store all the data in a separate partition. The disk defragmentation is then run regularly to ensure that there is no fragmentation in the partition of the storage web server data. Use NTFS to help reduce fragmentation. (7) Although SSL can provide fairly reliable encryption transmission. However, the additional overhead required can cause the IIS server to fall, especially when processing large files. So you should only make SSL encryption on the directory that does need protection.
4.2.1.4 Adjustment Distribution Time
HKEY_LOCAL_MACHINE / SYSTEM / CURRENTCONTROLSET / SERVICES / INETINFO / Parameters / ObjectCachettl = 0x8ca0.
4.2.1.5 Adjust the maximum number of threads
HKEY_LOCAL_MACHINE / SYSTEM / CURRENTCAL_MACHINE / SYSTEM / CURRENTCONTROLSET / SYSTEM / W3SVC / ASP / Parameters, increasing ProcessorthReadmax, reducing this value to see performance changes; or increase this value. )
4.2.1.6 Other Optimal Options in Registry
"HKEY_LOCAL_MACHINE / SYSTEM / CURRENTCONTROLSET / SERVICES / INETINFO / Parameters /" for parent nods;
CacheSecurityDescriptor Indicates whether security descriptors are cached for file objects. A value of 1 enables this feature. A value of 0 disables this feature. When enabled (the default setting), security descriptors for files are saved when caching a file object. As long as the file is cached, IIS will not need to re-access the file to determine access rights for new users. This value is most useful for sites that authenticate users and not useful for sites that allow anonymous access. CheckCertRevocation Indicates whether IIS checks to see if a client certificate is revoked. If you issue your own certificates and make local certificate checks, you might want to enable this feature. Otherwise, the feature should be disabled, which is the default. A value of 1 enables this feature. DisableMemoryCache Indicates WHETHER IIS Memory Caching Is Enabled or Disabled. by Default, Memory Caching IS Enabled (Meaning this value is set to 0). Disable memory caching only for testing or uspme nt purposes. ListenBackLog Specifies the maximum number of active connections that IIS maintains in the connection queue. The default value is 15 and the range of acceptable values is from 1 to 250. MaxCachedFileSize Determines the maximum size of a file that can be placed in the file cache. IIS will not cache files that are larger than this value. The default value is 262,144 bytes (256 KB). MaxConcurrency Specifies how many threads per processor should be allowed to run simultaneously if there is a pending input / output (I / O) Operation. The default value (0) Allows IIS to Control The Number of Threads Per Processor. You Can Also Set A Specific Value. MaxPoolthreads Sets The Number of Pool Threads to create Per processor.
Each pool thread watches for a network request for a CGI application and processes it. This value does not control threads that are used by ISAPI applications. By default, the value is set to 4. On a single processor system, this means that only four CGI applications could run simultaneously. MemCacheSize Sets the maximum amount of memory that IIS will use for its file cache. If IIS does not need this much memory, it will be left for other applications to use. By default, IIS uses 50 percent of the available memory. The valid range is from 0 megabytes to the total amount of physical memory available in megabytes. ObjectCacheTTL Sets the length of time (in milliseconds) that objects are held in memory. If the object has not been used in this interval, it is removed from memory. The default value is 30 seconds (300,000 milliseconds). PoolThreadLimit Sets the maximum number of pool threads that can be created on the server. This limit is for all IIS threads. The default value is twice the Size of Physical Memory in Megabytes.4.2.1.7 Disable Unnecessary Services:
Disable the Windows 2000 service that dedicated Web servers. Method is: Click Start, point to Programs, Administrative Tools, and then click Computer Management. Under "Computer Management (Local), expand Services and Applications, and then click Services. The status column currently running is displayed. The following services are not required on the dedicated web server: alarm scrapbook computer browser DHCP client DHCP server fax service file Copy infrared monitor Internet connection sharing letter make netmeeting remote desktop sharing network DDE network DDE DSDM NWLINK NETBIOS NWLINK IPX / SPX Backstage Print program TCP / IP NetBIOS support service phone telnet uninterruptible power supply ===================================== =========== Remember those services that have dependencies with the service you want to stop. The method is to double-click the required service. For example, double-click the messenger. Click the dependency tab. In the "Service Name Relying on these Service" list (where the service name is the name of the selected service), write down the service dependent on the service. In the "These Service Dependent Service Name" list, those services that do not start without the service. Click OK. Disable the required services. The method is: Right-click on the service you want to disable and click Properties on the shortcut menu that appears. In the Launch Type list, click Disable. If you want to stop using it now, click Stop. If there is a stopped other service dialog, other services that depend on the service will also be stopped. Remember the affected service, then click Yes. Click OK. Disable is displayed in the startup type column of the service. Repeated step 4 and disable other unnecessary services. Remarks: After all services are disabled, you should test whether the web server computer is operating normally. This reduces the impact of disabling the services that may be needed. Note: If the IIS server is a Windows 2000 domain member, the TCP / IP support service is required to properly apply the Group Policy to your computer. 4.2.1.8 Maximizing Network Application Data Throughput
Run the IIS 5.0 process can be paid page code in the work memory. The method is: Right-click on the desktop to click on the neighbor and click Properties in the shortcut menu that appears. Right-click the local connection icon you want and then click Properties in the shortcut menu that appears. In "This connection uses the following selected component" list, click "Microsoft Network and Printer Sharing" (but do not clear the check box), and then click Properties. Click "Maximize Network Application Data Throughput", then click OK twice
4.2.1.9 Optimizing the performance of the background service
IIS 5.0 Process (INetInfo.exe) is running as a background service. To improve the performance of the background service, follow these steps: Click Start, point to Settings, and then click Control Panel. Double-click the system in the Control Panel. Click the Advanced tab and click Performance Options. Under Application Response, click Background Service, and then click OK twice. Exit the Control Panel. 4.2.1.10 Minimize IIS 5.0 Log Record
It is forbidden to log records for unwanted Web sites, virtual directories, or files and folders. Method is: Click Start, point to Programs, Administrative Tools, and then click Internet Service Manager. Expand "* Server Name", where the server name is the name of the web server. Find the items you want, and then right-click this item. On the shortcut menu that appears, click Properties. For example, right-click the default Web site and click Properties on the shortcut menu that appears. Do one of the following: If you select a Web site, click the Main Directory tab. - Or - If you select a virtual directory, click the Virtual Directory tab. - Or - Click the Directory tab if you select an actual directory. Click the Log Access check box, clear it, and then click OK. To prohibit the logging of the entire Web site, click the Web Site tab, click Enable Log Release check box, clear it, and then click OK. Exit the Internet Information Services management unit.
4.2.1.11 Enable bandwidth limit
Limit the network bandwidth available for each Web site. The method is: Start "Internet Service Manager". Expand "* Server Name", where the server name is the name of the web server. Right-click on the desired Web site (for example, the default Web site), and then click Properties on the shortcut menu that appears. Click the Performance tab, and then click the Enable Bandwidth Restrictions check box to select it. In the "Maximum Network Usage" box, type the desired value, then click OK. Exit the Internet Information Services management unit.
4.2.1.12 Limiting processor use
Limit the web site to the processor's occupation. The method is: Start "Internet Service Manager". Expand "* Server Name", where the server name is the name of the web server. Right-click on the desired Web site (for example, the default Web site), and then click Properties on the shortcut menu that appears. Click the Performance tab, and then click the Enable Process Limit check box to select it. Type the desired value in the "Maximum Using the CPU" box. Click the Mandatory Restrictions check box, select it, and then click OK. Note: If the mandatory restriction option is not enabled, the "maximum use of CPU" is not enforced. When the Web site exceeds its allowed CPU usage limit, the event is written in the "Event Log". Exit the Internet Information Services management unit.
4.2.1.13 Restricting Web Site Connection
Restrict the number of connections available for each Web site. The method is: Start "Internet Service Manager". Expand "* Server Name", where the server name is the name of the web server. Right-click on the desired Web site (for example, the default Web site), and then click Properties on the shortcut menu that appears. Under the connection, click Limit. In the Connection box, type the number of connections to be allowed. Remarks: Connect each client of the connection uses four connections. For example, limit the number of connections to 200 approximately 50 users to access the Web site. Click OK, then exit the Internet Information Services management unit. 4.
2.1.14 Use "Keep HTTP Connection"
By default, "keep HTTP connection" can be used. To verify that "Keep HTTP Connection" is enabled, follow these steps: Start "Internet Service Manager". Expand "* Server Name", where the server name is the name of the web server. Right-click on the desired Web site (for example, the default Web site), and then click Properties on the shortcut menu that appears. Under the connection, confirm that the "Enable HTTP Connection" checkbox has been selected, and then click OK. Exit the Internet Information Services management unit.
4.2.2 Optimizing Configuration DBServer
4.2.2.1 SQLServer
Memory is an important factor affecting the performance of Microsoft SQL Server system. The SQL Server database is installed to have a machine with 32MB of physical memory by 16MB available memory. The 16MB physical memory machine default configuration 4MB available memory. You should have a memory option (Memory) settings after the Microsoft SQL Server database is installed. To determine the most suitable memory requirements of the SQL Server system, you can subtract the memory required by Windows 2000 Server from the total physical memory and other memory demands. The following is the SQL Server Memory Options (1) Start SQL Enterprise Manager from the Microsoft SQL Server program; (2) Select the Server menu option from the Server Manager window; (3) In the Server menu Select "Configuration" option; (4) Select "Configuration" tab in the "Server Configuration" dialog, (5) Select the "Memory" project, fill in the new value in the "current" bar; (6) Stop and restart SQLServer Service makes the settings take effect. Reasonably expand virtual memory, increasing SQL Server Available Memory When the SQL Server system does need to expand the available memory, the virtual memory should be expanded in the case of sufficient disk space, and increase the SQL Server available memory. The specific method is that the system administrator first expands the virtual memory of the server, and then refer to the above table to increase the SQL Server available memory, the key is to determine whether to expand whether the system's load condition is integrated. Use the Tempinram SQL Server to use the Tempdb temporary database as some of the workspaces that are sorted or created during the query connection operation. Creating Tempdb in RAM can make system operation performance has greatly improved, and because Tempdb is reconstructed when the server is restarted, even if there is abnormal shutdown, it is also safer, such as a power failure. To create Tempdb in RAM, you can use sp_configure to set up, please refer to the information. Since the memory used by Tempdbinram is separately assigned by the system, the available memory pool set to SQL Server's memory option is separate. Using Tempdbin RAM will reduce the available memory of the entire system, should be based on SQL Server and server operation Configuration, otherwise it may be reversed and affect system performance. In addition, the TEMPDB database space is increased, even if the Tempdbin RAM is not used, it can also improve the running speed of the database. Note: Do not set less than 32MB of memory in the production environment, and the database server is expanded as possible to the virtual memory, increase SQL Server available memory, should consider physical memory usage and disk space; where possible, The system has some additional memory so that the server is opened on the server or adds a process without changing the SQL Server memory configuration, and does not affect the running speed of the NT server (becomes very slow). It is generally considered to be 2MB. Maximum is 20MB. 4.2.3 Hardware improvement
4.2.3.1 CPU / Memory
If the test determines that there is a processor problem, your first selection is of course the upgrade or switch to multiprocessor computers. If you are determined to upgrade the processor, make sure it has the largest L2 cache, IIS will benefit, because many of its instruction paths include multiple components, and their speed speed is greatly accelerated during the cache. Computer Name / Memory / Availability Memory - The total amount of available memory in this counter trace system. The operating system attempts to keep this value over 4 MB. To achieve optimal performance, this value is preferably 5% of the total memory.
4.2.3.2 Dish Do not store the log file with the web page on the same hard disk. This will prevent the hard disk logging thread intervene to retrieve the thread of the web page. Optimize web page storage. All related web pages on the site should be stored in the same logical partition, which improves the performance of the file system cache. At the same time, the web page file should not have any pieces, which can greatly speed to read the speed of a single file. If you use Ultra2's SCSI hard drive, you can significantly improve IIS performance. Network interface card, the upgrade of memory is naturally not much.
5 session management
The HTTP protocol can achieve such a large success, its design achieved simple and stateless connection high efficiency is very important. In order to achieve a balance between the stateless HTTP request and the stateful client operation, the concept of server-side session is generated. The introduction of Session is very convenient for web programming, but the corresponding session management is extremely important. Current ASP.NET can be managed through the "Process", "Procedure-specific Status Management" and "SQL Server Status Service Management". For the default "process" management, only the memory-based state management is implemented in a process, there is a lot of problems:
1. All session data is saved in the process of Web services, resulting in a restriction problem that the server supports session is subject to server memory resources, and because of a large number of non-active sessions, memory is not occupied.
2. Server process crashes will result in all session data loss.
Back to our actual system, we currently use the session variables to have four uses:
Figure 5-1 Single range of session variables
Obviously, the first three methods are small data, we mainly pay attention to the fourth way - the interval variable.
Putting the entire data in the session, mainly for subsequent processing or secondary processing or user flipping, in general, we will ignore the size of the data set to Web-Server and interactive time when encoding. The impact. In fact, a large data set (the number of records is more than 100,000) is considerable, and if there are several concurrent, the memory of Web-Server will be sharply tight. The following table is the statistics on the actual test of SQL execution time.
Record number (10,000) Execution time (seconds) 10 4 11 6 15 10 20 11 30 12 40 16 50 19
Table 5-1 Data query execution time statistics table
There is a solution to save the "query condition" of complex queries in the session. This method is simple and light, but it will also cause "DB-Server busy" due to frequent query (500,000 recorded query time is greater than 15s); the ideal solution is to achieve pagination or say when the database query is You can query by page. At this time, you can only store query conditions in the session because the amount of interaction is not large. This function can be easily implemented in Oracle and SQLServer 2005, but it is more troublesome in SQLServer2000, which is generally used in stored procedures.
Considering that the existing system does not consider the amount of large data in the implementation, it is not a large amount of data, which should not be used in a single session management scheme. In fact, we can construct an adaptive data access actuator and session manager, dynamically returns and store execution results in different ways. Since the SESSION management mode of the current system is "Input" mode and since IIS does not provide a smooth configurable secondary (memory / hard disk) cache media switching, virtual storage is constructed, and the virtual storage is possible to mitigate concurrent pressure. Below is the overall structure of the program:
Figure 5-2 Global session management structure
First, let's take a look at the flow chart of data access execution (Figure 5-3).
As can be seen from Figure 5-3, we set a time threshold when performing a query. If the data is performed in the specified time, the amount of data is not very large, then return the result set to the front desk; if it is timeout, it will return one Small datasets (such as TOP 1000), then continue to query the action in the background, save the final result set to session, pay attention to the data set at this time is very large, but may also be waiting due to the busyness of the server. So we will save it through the SESSION Manager to save. Figure 5-3 Data Access Actuator Flow Diagram
The following is a brief schematic of the SessionManager class.
Figure 5-4 PageSessionManager class structure simple schematic
It must be noted that this is just a simple schematic, which is greatly enriched during the specific implementation. For example, add the current session save mode and the number of saves. The purpose of implementing the PageSessionManager is to specify the use of session, especially the SESSION dataset variable, we automatically select storage mode according to the size of the data set, which is a flow chart for storing the session dataset variable.
Figure 5-5 Save data set variable flow chart
It can be seen that we introduce a new storage method in SessionManager - Virtual Store. Its purpose is obviously to relieve the WEB-Server memory pressure, improve concurrent. After testing, this approach is still relatively fast; if the XML is saved to the database, the timeout exception occurs when the XML or read XML is acquired. In fact, we construct a procedural session manager yourself, then naturally need to perform session cleanup and failure management, we can run a special failure management process in the background, and the specific implementation method can refer to the figure below.
Figure 5-6 Virtual Storage Schematic
Another problem is how the virtual storage file is established with the correspondence between the HTTP process. This is not difficult, we only need to create a GUID store in the actual session of the same name, the file name of the virtual session is identified by this GUID.
Corresponding to the storage, when the sessionManager gets the session value, the sessionmanager must automatically feed back the corresponding results according to the current storage method, and its implementation process is not complicated, and it will not be described here.
Overall, this solution is characterized by increasing and promptly responding, but the processing of certain issues is inconvenient. For example, the query is required to get all the data sets (even very) when the query is required for the secondary processing. At this time, the corresponding attribute value must be set to tell AdaptiveExecutor to make it executed in the specified manner; The control cannot be instantaneously obtained at the end of the query.
6 code
The code level herein refers to an improvement in the algorithm for specific code implementations, especially a certain business logic. An example of being in the preface is the code optimization. Code optimization is deep, need to be very familiar with business logic and data stream, so difficulty is also the largest. But after the business logic is removed, we can still reach a consensus on the encoding skills or algorithm structure. This article mainly lists the methods and attention points and attention of performance considerations based on performance considerations during actual coding.
• Don't use unnecessary sessions, like ASP, don't use session when you don't have need.
• Do not use unnecessary Server Control
• Do not use unnecessary ViewState
• Do not use the Exception control program process
• Disable VB and JScript dynamic data types
• Complete data access using the stored procedure
• Read-only data access Don't use DataSet
• Close the Debug mode of ASP.NET
• Use ASP.NET OUTPUT CACHE Buffer Data • Try to return DataGrid with SQL to be bound to DataSet, try not to make a secondary processing for DataSet, especially do not delete DataSet, and practice prove this very slow. It is better to copy some data.
• Try not to follow DataSet secondary processing or by DataSet, it is obvious, if there are 40000 records, it means to fight> = 40000 objects
• Try to compress the number of database operations in query data to the least, try to complete the database operation; if each data of the Dataset obtained is queried, then if there is 40,000 records, at least 400001 database operations, plus traversal DataSet, the time to generate objects, is quite amazing
• Pay attention to optimizing database query operations, such as no conditional queries, do not take one by a discrete value;
• Note that limit large data query operations, such as expecting a page if there is a lot of data if a condition will appear, then force at least one query condition;
• Do not select all data by default when loading, although it can be easily follow-up, but users will "so slowly" yet. "
• It is recommended to use a relatively efficient SQL to replace subsequent complex DataSet secondary processing.
• Open database connection only when needed
• Once the database is complete, turn off the connection
• Remember to delete temporary objects when turning off the connection
• Make sure to close any user-defined transactions before turning off the connection
• To use the connection pool, do not use the application role (Application Roles)
• Display non-interactive data, you can get the best performance using SqlDataReader
• Format data with DataGrid Component is displayed with better performance by getting an HTML code in SQL.
• In general, use an index (index) in the cycle than using a collection (Collection) better performance. Because the CLR (Common Language Runtime can sometimes optimize according to the data index, but the collection is
• CAUTION Sharing data obtained by complex processing or long queries
• Remember to terminate the current page during page
• If there are some data that is not related to processing logic in the page load or background calculation, you can consider using multi-thread; page loading can also be considered step-by-step loading (response.flush ())
• There is a large number of connected string operations do not use , modify StringBuilder
7 Reference
1. http://www.microsoft.com/technet/prodtechnol/windows2000serve/technologies/iis/maintain/optimize/perflink.mspx
2. http://www0.ccidnet.com/tech/web/2001/09/28/58_3369.html
3. http://msdn.microsoft.com/library/chs/default.asp?url=/library/chs/cpguide/html/cpconaspoptimization.asp
4. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt06.asp
5. http://www.microsoft.com/china/technet/itsolutions/net/maintain/netopsgd.asp6. Http://www.programfan.com/showArticle.asp?id=2548
7. http://www.microsoft.com/china/msdn/library/webservices/asp.net/cachingnt2.mspx
8. http://www.programfan.com/showArticle.asp?id=2548
9. http://www.microsoft.com/chna/msdn/library/webservices/asp.net/cachingnt2.mspx
10. http://www.sql-server-performance.com/ASP_NET_PERFORMANCE.ASP
11. http://www.cnblogs.com/flier/archive/2004/08.html
12. http://soft.yesky.com/softchannel/72342380468043776/2005023/1914105.shtml
13. http://jibbering.com/2002/4/HttpRequest.html