ASP Performance Tips
Performance goals vary from application to application. You should set your goals to correspond with your expected user traffic. In general, you should aim for 20 pages or more per second with less than 30 percent CPU utilization, and response times of 10 seconds or less. The following list includes tips you can use to achieve your ASP performance objectives:
- Retrieving values from collections is relatively slow. Store retrieved values in local variables if you need to access them more than once.
- Avoid using server-side #include directives to include large lists of constants. Use the new <METADATA> tag to import type-library constants into global.asa.
- Avoid using Server.CreateObject. Use <OBJECT> tags instead.
- Group multiple Response.Write statements, and delimit them with one set of <% %> delimiters.
- Avoid redimensioning VBScript arrays.
- Use only one scripting language per page.
- Buffered responses (Response.Buffer=True) are faster than unbuffered ones (although they can appear less responsive).
- Use Response.IsClientConnected during the processing of long scripts. This property determines if the client has disconnected from the server since the last Response.Write, and improves application responsiveness during times of peak usage.
- Use components to encapsulate business logic rather than complex script.
- Convert dynamic ASP output to static HTML using the ASP2HTM component wherever possible. (ASP2HTM is included on the Internet Information Server (IIS) Resource Kit CD.)
- Store commonly requested, unchanging content in memory using an application-scope Dictionary object.
- Avoid using Session_OnEnd event procedures, if possible.
- Disable the Session object on a page-by-page basis with the <%@ EnableSessionState=False %> statement. This declarative allows ASP to process scripts concurrently, rather than sequentially.
- Write client scripts that don't require roundtrips to the server. Distribute work to the client, such as form input validation. Use the Browser Capabilities component (MSWC.BrowserType) and customize client-side scripts to take advantage of the browser, incorporating such technologies as DHTML, client-side script, and ActiveX® controls.
- Focus your optimization efforts on the most common paths through your site or application. You can determine user behavior with IIS service logs and the Usage Import and Report Writer component of Site Server Express.
- Set Response.Expires appropriately so that proxy servers can intelligently cache information that doesn't change often.
- Optimize the use of ADO Connection objects, with ODBC connection pooling and stored procedures.
- Measure system performance with tools such as Task Manager, NetMon, and PerfMon. Measure Web capacity with WCAT. Profile portions of your ASP script with the ASP Tracer component. For more information see the IIS Resource Kit.