microsoft's 25+ asp tips

Upload: sujith03

Post on 09-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 Microsoft's 25+ ASP Tips

    1/17

    All Products | Support | Search | microsoft.com

    chNet Home | Site Map | Events | Downloads | Personalize | Worldwide |

    25+ ASP Tips to Improve Performance and Style

    Topics on this Page

    Introduction

    Tip 1: Cache Frequently-Used Data on the Web Server

    Tip 2: Cache Frequently-Used Data in the Application or Session Objects

    Tip 3: Cache Data and HTML on the Web Servers Disks

    Tip 4: Avoid Caching Non-Agile Components in the Application or Session Objects

    Tip 5: Do Not Cache Database Connections in the Application or Session Objects

    Tip 6: Use the Session Object Wisely

    Tip 7: Encapsulate Code in COM Objects

    Tip 8: Acquire Resources Late, Release Early

    Tip 9: Out-of-Process Execution Trades Off Performance for Reliability

    Tip 10: Use Option Explicit

    Tip 11: Use Local Variables in Subroutines and Functions

    Tip 12: Copy Frequently-Used Data to Script Variables

    Tip 13: Avoid Redimensioning Arrays

    Tip 14: Use Response Buffering

    Tip 15: Batch Inline Script and Response.Write Statements

    Tip 16: Use Response.IsClientConnected Before Embarking on Long Trips

    Tip 17: Instantiate Objects Using the Tag

    Tip 18: Use TypeLib Binding for ADO and Other Components

    Tip 19: Take Advantage of Your Browsers Validation Abilities

    Tip 20: Avoid String Concatenation in Loops

    Tip 21: Enable Browser and Proxy CachingTip 22: Use Server.Transfer Instead of Response.Redirect Whenever Possible

    Tip 23: Use Trailing Slashes in Directory URLs

    Tip 24: Avoid Using Server Variables

    Tip 25: Upgrade to the Latest and Greatest

    Tip 26: Tune Your Web Server

    Tip 27: Do Performance Testing

    Tip 28: Read the Resource Links

    Len Cardinal, Senior Consultant, Microsoft Consulting ServicesGeorge V. Reilly, Microsoft IIS Performance Lead

    Adapted from an article by Nancy ClutsDeveloper Technology EngineerMicrosoft Corporation

    Updated: April 2000

    Summary: This article presents tips for optimizing ASP applications and VBScript.

    Introduction

    Performance is a feature. You need to design for performance up front, or you get to rewrite your application later on.That said, what are some good strategies for maximizing the performance of your Active Server Pages (ASP) application?

    http://www.microsoft.com/isapi/gomscom.asp?target=/products/http://www.microsoft.com/isapi/gomscom.asp?target=/support/http://www.microsoft.com/isapi/gosearch.asp?target=/http://www.microsoft.com/isapi/gomscom.asp?target=/http://www.microsoft.com/technet/default.asphttp://www.microsoft.com/technet/sitemap/default.asphttp://www.microsoft.com/technet/events/default.asphttp://www.microsoft.com/technet/download/default.asphttp://register.microsoft.com/personalize/default.asp?DM=2&fu=http://www.microsoft.com/technet/library/home/getpersonalized.asphttp://www.microsoft.com/technet/worldwide/default.asphttp://www.microsoft.com/technet/worldwide/default.asphttp://register.microsoft.com/personalize/default.asp?DM=2&fu=http://www.microsoft.com/technet/library/home/getpersonalized.asphttp://www.microsoft.com/technet/download/default.asphttp://www.microsoft.com/technet/events/default.asphttp://www.microsoft.com/technet/sitemap/default.asphttp://www.microsoft.com/technet/default.asphttp://www.microsoft.com/isapi/gomscom.asp?target=/http://www.microsoft.com/isapi/gomscom.asp?target=/http://www.microsoft.com/isapi/gosearch.asp?target=/http://www.microsoft.com/isapi/gomscom.asp?target=/support/http://www.microsoft.com/isapi/gomscom.asp?target=/products/http://www.microsoft.com/technet/default.asp
  • 8/7/2019 Microsoft's 25+ ASP Tips

    2/17

    This article presents tips for optimizing ASP applications and Visual Basic Scripting Edition (VBScript). Many traps andpitfalls are discussed. The suggestions listed in this article have been tested on http://www.microsoft.com and other

    sites, and work very well. This article assumes that you have a basic understanding of ASP development, includingVBScript and/or JScript, ASP Applications, ASP Sessions, and the other ASP intrinsic objects (Request, Response, andServer).

    Often, ASP performance depends on much more than the ASP code itself. Rather than cover all wisdom in one article, welist performance-related resources at the end. These links cover both ASP and non-ASP topics, including ActiveX DataObjects (ADO), Component Object Model (COM), databases, and Internet Information Server (IIS) configuration. Theseare some of our favorite linksbe sure to give them a look.

    Tip 1: Cache Frequently-Used Data on the Web Server

    A typical ASP page retrieves data from a back-end data store, then paints the results into Hypertext Markup Language(HTML). Regardless of the speed of your database, retrieving data from memory is a lot faster than retrieving data froma back-end data store. Reading data from a local hard disk is also usually faster than retrieving data from a database.Therefore, you can usually increase performance by caching data on the Web server, either in memory or on disk.

    Caching is a classic space-for-time tradeoff. If you cache the right stuff, you can see impressive boosts in performance.For a cache to be effective, it must hold data that is reused frequently, and that data must be (moderately) expensive torecompute. A cache full of stale data is a waste of memory.

    Data that does not change frequently makes good candidates for caching, because you don't have to worry aboutsynchronizing the data with the database over time. Combo-box lists, reference tables, DHTML scraps, ExtensibleMarkup Language (XML) strings, menu items, and site configuration variables (including data source names (DSNs),Internet Protocol (IP) addresses, and Web paths) are good candidates for caching. Note that you can cache the

    presentation of data rather than the data itself. If an ASP page changes infrequently and is expensive to cache (forexample, your entire product catalog), consider pregenerating the HTML, rather than repainting it for every request.

    Where should data be cached, and what are some caching strategies? Data is often cached either in the Web server'smemory or on the Web server's disks. The next two tips cover these options.

    Tip 2: Cache Frequently-Used Data in the Application or Session Objects

    The ASP Application and Session objects provide convenient containers for caching data in memory. You can assigndata to both Application and Session objects, and this data will remain in memory between HTTP calls. Session data isstored per user, while Application data is shared between all users.

    At what point do you load data into the Application or Session? Often, the data is loaded when an Application or Sessionstarts. To load data during Application or Session startup, add appropriate code to Application_OnStart() orSession_OnStart(), respectively. These functions should be located in Global.asa; if they are not, you can add thesefunctions. You can also load the data when it's first needed. To do this, add some code (or write a reusable scriptfunction) to your ASP page that checks for the existence of the data and loads the data if it's not there. This is anexample of the classic performance technique known as lazy evaluationdon't calculate something until you know youneed it. An example:

    Similar functions could be written for each chunk of data needed.

    In what format should the data be stored? Any variant type can be stored, since all script variables are variants. Forinstance, you can store strings, integers, or arrays. Often, you'll be storing the contents of an ADO recordset in one ofthese variable types. To get data out of an ADO recordset, you can manually copy the data into VBScript variables, onefield at a time. It's faster and easier to use one of the ADO recordset persistence functions GetRows(),GetString()orSave()(ADO 2.5). Full details are beyond the scope of this article, but here's a function that demonstrates usingGetRows() to return an array of recordset data:

    ' Get Recordset, return as an ArrayFunction FetchEmploymentStatusList

    http://www.microsoft.com/http://www.microsoft.com/
  • 8/7/2019 Microsoft's 25+ ASP Tips

    3/17

    Dim rsSet rs = CreateObject(?ADODB.Recordset?)rs.Open ?select StatusName, StatusID from EmployeeStatus?, _?dsn=employees;uid=sa;pwd=;?FetchEmploymentStatusList = rs.GetRows() ? Return data as an Arrayrs.CloseSet rs = NothingEnd Function

    A further refinement of the above might be to cache the HTML for the list, rather than the array. Here's a simple sample

    ' Get Recordset, return as HTML Option listFunction FetchEmploymentStatusListDim rs, fldName, s

    Set rs = CreateObject(?ADODB.Recordset?)rs.Open ?select StatusName, StatusID from EmployeeStatus?, _?dsn=employees;uid=sa;pwd=;?s = ?? & vbCrLfSet fldName = rs.Fields(?StatusName?) ' ADO Field BindingDo Until rs.EOF' Next line violates Don't Do String Concats,' but it's OK because we are building a caches = s &? ? &fldName &?? & vbCrLfrs.MoveNextLoops = s &?? & vbCrLfrs.CloseSet rs = Nothing ' See Release EarlyFetchEmploymentStatusList = s ' Return data as a StringEnd Function

    Under the right conditions, you can cache ADO recordsets themselves in Application or Session scope. There are twocaveats:

    ADO must be marked Free-threadedq

    You need to use a disconnected recordset.q

    If you cannot guarantee that these two requirements will be met, do not cache ADO recordsets. In the Non-AgileComponents and Don't Cache Connections tips below, we discuss the dangers of storing COM objects in Application orSession scope.

    When you store data in Application or Session scope, the data will remain there until you programmatically change it,the Session expires, or the Web application is restarted. What if the data needs to be updated? To manually force anupdate of Application data, you can call into an administrator-access-only ASP page that updates the data. Alternatively,you can automatically refresh your data periodically through a function. The following example stores a time stamp withthe cached data and refreshes the data after a certain time interval.

  • 8/7/2019 Microsoft's 25+ ASP Tips

    4/17

    Be aware that caching large arrays in Session or Application objects is not a good idea. Before you can access anyelement of the array, the semantics of the scripting languages require that a temporary copy of the entire array bemade. For example, if you cache a 100,000-element array of strings that maps U.S. zip codes to local weather stationsin the Application object, ASP must first copy all 100,000 weather stations into a temporary array before it can extractjust one string. In this case, it would be much better to build a custom component with a custom method to store theweather stationsor to use one of the dictionary components.

    One more comment in the spirit of not throwing out the baby with the bath water: Arrays provide fast lookup andstorage of key-data pairs that are contiguous in memory. Indexing a dictionary is slower than indexing an array. Youshould choose the data structure that offers the best performance for your situation.

    Tip 3: Cache Data and HTML on the Web Server's Disks

    Sometimes, you may have too much data to cache in memory. "Too much" is a judgment call; it depends on how muchmemory you want to consume, as well as the number of items to cache and the frequency of which these items will beretrieved. In any case, if you have too much data for in-memory caching, consider caching data in text or XML files onthe Web servers' hard disks. You can combine caching data on disks and in memory to build the optimum cachingstrategy for your site.

    Note that when measuring the performance of a single ASP page, retrieving data on disk may not always be faster thanretrieving the data from a database. But caching reduces load on the database and on the network. Under high loads,this will greatly improve overall throughput. Caching can be very effective when caching the results of an expensivequery, such as a multitable join or a complex stored procedure, or caching large result sets. As always, test competingschemes.

    ASP and COM provide several tools for building disk-based caching schemes. The ADO recordset Save() and Open()functions save and load recordsets from disk. You could use these methods to rewrite the sample code from theApplication data caching tip, above, substituting a Save() to file for the code that writes to the Application object.

    There are a few other components that work with files:

    Scripting.FileSystemObject allows you to create, read, and write files.q

    MSXML, the Microsoft XML parser that comes with Internet Explorer, supports saving and loading XMLdocuments.

    q

    The LookupTable object (sample, used on MSN) is a great choice for loading simple lists from disk.q

    Finally, consider caching the presentation of data on disk, rather than the data itself. Prerendered HTML can be stored asan .htm or .asp file on disk; hyperlinks can point to these files directly. You can automate the process of generatingHTML using commercial tools such as XBuilder, or Microsoft SQL Server Internet publishing features. Alternatively,you can #include HTML snippets into an .asp file. You can also read HTML files from disk using the FileSystemObject,

    or use XML for early rendering.Tip 4: Avoid Caching Non-Agile Components in the Application or Session Objects

    While caching data in the Application or Session object can be a good idea, caching COM objects can have seriouspitfalls. It is often tempting to stuff frequently-used COM objects into the Application or Session objects.Unfortunately, many COM objects, including all of those written in Visual Basic 6.0 or earlier, can cause seriousbottlenecks when stored in the Application or Session objects.

    Specifically, any component that is not agile will cause performance bottlenecks when cached in the Session orApplication objects. An agile component is a component marked ThreadingModel=Both that aggregates theFree-threaded marshaler (FTM), or is a component that is marked ThreadingModel=Neutral. (The Neutral model isnew to Windows 2000 and COM+.) The following components are not agile:

    Free-threaded components (unless they aggregate the FTM).q

    Apartment-threaded components.q

    Single-threaded component.q

    Configured components (Microsoft Transaction Server (MTS)/COM+ library and server packages/applications) are notagile unless they are Neutral-threaded. Apartment-threaded components and other non-agile components work best atpage scope (that is, they are created and destroyed on a single ASP page).

    In IIS 4.0, a component marked ThreadingModel=Both was considered agile. In IIS 5.0, that is no longer sufficient. Thecomponent must not only be marked Both, it must also aggregate the FTM. The agility article describes how to makeC++ components written with the Active Template Library aggregate the FTM. Be aware that if your component cachesinterface pointers, those pointers must themselves be agile, or must be stored in the COM Global Interface Table (GIT).If you can't recompile a Both-threaded component to aggregate the FTM, you can mark the component as

  • 8/7/2019 Microsoft's 25+ ASP Tips

    5/17

    ThreadingModel=Neutral. Alternatively, if you don't want IIS performing the agility check (thus, you want to allownon-agile components to be stored at Application or Session scope), you can set AspTrackThreadingModel to True inthe metabase. Changing AspTrackThreadingModel is not recommended.

    IIS 5.0 will throw an error if you attempt to store a non-agile component created with Server.CreateObject in theApplication object. You can work around this by using in Global.asabut this is not recommended, as it leads to marshaling and serialization, as explained below.

    What goes wrong if you cache non-agile components? A non-agile component cached in the Session object will "lockdown" the Session to an ASP worker thread. ASP maintains a pool of worker threads that services requests. Normally, anew request is handled by the first-available worker thread. If a Session is locked down to a thread, then the requesthas to wait for its associated thread to become available. Here's an analogy that might help: you go to a supermarket,

    select some groceries, and pay for them at checkout stand #3. Thereafter, whenever you pay for groceries at thatsupermarket, you always have to pay for them at stand #3, even though other checkout stands might have shorter oreven empty lines.

    Storing non-agile components at Application scope has an even worse effect on performance. ASP has to create a speciathread to run non-agile, Application-scoped components. This has two consequences: all calls have to be marshaled tothis thread and all calls are serialized. Marshaling means that the parameters have to be stored in a shared area ofmemory; an expensive context switch is made to the special thread; the component's method is executed; the resultsare marshaled into a shared area; and another expensive context switch reverts control to the original thread.Serialization means that all methods are run one at a time. It is not possible for two different ASP worker threads to beexecuting methods on the shared component simultaneously. This kills concurrency, especially on multiprocessormachines. Worse still, all non-agile Application-scoped components share one thread (the "Host STA"), so the effects ofserialization are even more marked.

    Confused? Here are some general rules. If you are writing objects in Visual Basic (6.0) or earlier, do not cache them in

    the Application or Session objects. If you don't know an object's threading model, don't cache it. Instead of cachingnon-agile objects, you should create and release them on each page. The objects will run directly on the ASP workerthread, so there will be no marshaling or serialization. Performance will be adequate if the COM objects are running onthe IIS box, and if they don't take a long time to initialize and destroy. Note that Single-threaded objects should not beused this way. Be carefulVB can create Single-threaded objects! If you have to use Single-threaded objects this way(such as a Microsoft Excel spreadsheet) don't expect high throughput.

    ADO recordsets can be safely cached when ADO is marked as Free-threaded. To mark ADO as Free-threaded, use theMakfre15.bat file, which is typically located in the directory \\Program Files\Common\System\ADO.

    Warning ADO should not be marked as Free-threaded if you are using Microsoft Access as your database. The ADOrecordset must also be disconnected In general, if you cannot control the ADO configuration on your site (for example,you are an independent software vendor [ISV] who sells a Web application to customers who will manage their ownconfigurations), you are probably better off not caching recordsets.

    Dictionary components are also agile objects. The LookupTable loads its data from a data file and is useful forcombo-box data as well as configuration information. The PageCache object from Duwamish Books provides dictionarysemantics, as does the Caprock Dictionary. These objects, or derivatives thereof, can form the basis of an effectivecaching strategy. Note that the Scripting.Dictionary object is NOT agile, and should not be stored at Application orSession scope.

    Tip 5: Do Not Cache Database Connections in the Application or Session Objects

    Caching ADO Connections is usually a bad strategy. If one Connection object is stored in the Application object andused on all pages, then all pages will contend for use of this connection. If the Connection object is stored in the ASPSession object, then a database connection will be created for every user. This defeats the benefits of connectionpooling and puts unnecessarily high stress on both the Web server and the database.

    Instead of caching database connections, create and destroy ADO objects on every ASP page that uses ADO. This is

    efficient because IIS has database connection pooling built in. More accurately, IIS automatically enables OLEDB andODBC connection pooling. This ensures that creating and destroying connections on each page will be efficient.

    Since connected recordsets store a reference to a database connection, it follows that you should not cache connectedrecordsets in the Application or Session objects. However, you can safely cache disconnected recordsets, which don'thold a reference to their data connection. To disconnect a recordset, take the following two steps:

    Set rs = Server.CreateObject(?ADODB.RecordSet?)rs.CursorLocation = adUseClient ' step 1

    ' Populate the recordset with datars.Open strQuery, strProv

    ' Now disconnect the recordset from the data provider and data sourcers.ActiveConnection = Nothing ' step 2

  • 8/7/2019 Microsoft's 25+ ASP Tips

    6/17

    More information about connection pooling can be found in the ADO and SQL Server references.

    Tip 6: Using the Session Object Wisely

    Now that we've espoused the virtues of caching in Applications and Sessions, we're going to suggest avoiding theSession object. Sessions have several pitfalls when used with busy sites, as we'll discuss. By busy, we generally meansites requiring hundreds of pages a second or thousands of simultaneous users. This tip is even more important for sitesthat must scale horizontallythat is, those sites that utilize multiple servers to accommodate load or implement faulttolerance. For smaller sites, such as intranet sites, the conveniences of Sessions are worth the overhead.

    To recap, ASP automatically creates a Session for every user that hits a Web server. Each Session has about 10 KB of

    memory overhead (on top of whatever data is stored in the Session), and slows all requests down a bit. The Sessionstays alive until a configurable timeout period, usually 20 minutes.

    The biggest issue with Sessions is not performance but scalability. Sessions don't span Web servers; once a Session iscreated on one server, its data stays there. This means that if you use Sessions in a Web farm, you have to devise astrategy for each user's requests to always be directed to the server on which the user's Session exists. This is referredto as "sticking" a user to a Web server. The term "sticky sessions" derives from this. "Stuck" users will lose their Sessionstate if the Web server crashes, since Sessions are not persisted to disk.

    Strategies for implementing sticky sessions include hardware and software solutions. Solutions such as Network LoadBalancing in Windows 2000 Advanced Server and Cisco's Local Director can implement sticky sessions, at the cost ofsome scalability. These solutions are not perfect. Rolling your own software solution at this point of time is notrecommended (we used to use ISAPI filters and URL mangling and such).

    The Application object doesn't span servers either; if you need to share and update Application data across the Web

    farm, you'll need to use a back-end database. Read-only Application data is still useful in Web farms, however.

    Most mission-critical sites will want to deploy at least two Web servers, if for no other reason than increasing uptime(handling failover and server maintenance). Therefore, in designing your mission-critical application, you'll need to eitheimplement "sticky sessions," or simply avoid Sessions, as well as any other state-management technique that storesuser state on individual Web servers.

    If you are not using Sessions, be sure to turn them off. You can do this for your application through the InternetServices Manager (see the ISM documentation). If you decide to use Sessions, you can minimize their performanceimpact in several ways.

    You can move content that doesn't require Sessions (such as Help screens, visitor areas, and so forth.) into a separateASP application that has Sessions turned off. On a page-by-page basis, you can provide a hint to ASP that you won'tneed the Session object on a given page; use the following directive placed at the top your ASP page:

    One good reason to use this directive is that Sessions create an interesting problem with framesets. ASP guarantees thatonly one request from a Session will be executing at any time. This insures that if a browser requests multiple pages forone user, only one ASP request will touch the Session at a time; this avoids multithreading problems when accessing theSession object. Unfortunately, as a result, all pages in a frameset will be painted in a serialized manner, one afteranother, rather than simultaneously. The user may have to wait a long time for all of the frames. The moral of the storyif certain frameset pages have no reliance on the Session, be sure to tell ASP, using the @EnableSessionState=Falsedirective.

    As an alternative to using the Session object, there are many options for managing Session state. For small amounts ofstate (less than 4 KB), we usually recommend using Cookies, QueryString variables, and hidden-form variables. Forlarger amounts of data such as shopping carts, a back-end database is the most appropriate choice. A lot has beenwritten about state-management techniques in Web server farms. See the Session state references for more details.

    Tip 7: Encapsulate Code in COM Objects

    If you have a lot of VBScript or JScript, you can often improve performance by moving the code to a compiled COMobject. Compiled code typically runs faster than interpreted code. Compiled COM objects can access other COM objectsthrough "early binding," a more efficient means of invoking COM object methods than the "late binding" employed byscript.

    There are advantages (beyond performance) to encapsulating code in COM objects:

    COM objects are good for separating presentation logic from business logic.q

    COM objects enable code reuse.q

    Many developers find code written in VB, C++, or Visual J++ easier to debug than ASP.q

  • 8/7/2019 Microsoft's 25+ ASP Tips

    7/17

    COM objects have disadvantages, including initial development time and the need for different programming skills. Bewarned that encapsulating small amounts of ASP may cause performance penalties, rather than gains. Typically, thishappens when a small amount of ASP code is wrapped into a COM object. In this case, the overhead of creating andinvoking the COM object outweighs the benefit of the compiled code. It is a matter of trial and error to determine whatcombination of ASP script and COM object code produces the best performance. Note that Microsoft has vastly improvedscript and ADO performance in Windows 2000/IIS 5.0 over Windows NT 4.0/IIS 4.0. Thus, the performance advantageenjoyed by compiled code over ASP code has decreased with the introduction of IIS 5.0.

    For great discussions about the benefits and pitfalls of using COM objects in ASP, see ASP Component Guidelines andProgramming Distributed Applications with COM and Microsoft Visual Basic 6.0. If you do deploy COM components, it isparticularly important that you stress test them. In fact, all ASP applications should be stress tested as a matter ofcourse.

    Tip 8: Acquire Resources Late, Release Early

    Here's a short tip for you. In general, it's best to acquire resources late and release them early. This goes for COMobjects as well as file handles and other resources.

    ADO Connections and recordsets are the prime candidates for this optimization. When you are done using a recordset,say after painting a table with its data, release it immediately, rather than waiting until the end of the page. Setting yourVBScript variable to Nothing is a best practice. Don't let the recordset simply fall out of scope. Also, release any relatedCommand or Connection objects. (Don't forget to call Close() on recordsets or Connections before setting them =Nothing.) This shortens the time span in which the database must juggle resources for you, and releases the databaseconnection to the connection pool as quickly as possible.

    Tip 9: Out-of-Process Execution Trades off Performance for Reliability

    Both ASP and MTS/COM+ have configuration options that allow you to trade off reliability for performance. You shouldunderstand these trade-offs when building and deploying your application.

    ASP Options

    ASP Applications can be configured to run in one of three ways. With IIS 5.0, the terminology "isolation level" has beenintroduced to describe these options. The three isolation level values are Low , Medium, and High:

    Low Isolation. This is supported in all versions of IIS and is the fastest. It runs ASP in Inetinfo.exe, which is theprimary IIS process. If the ASP application crashes, so does IIS. (To restart IIS under IIS 4.0, Webmasterswould monitor the site using tools such as InetMon, and fire off batch files to restart the server if it failed. IIS5.0 introduces reliable restart, which automatically restarts a failed server.)

    q

    Medium Isolation. IIS 5.0 introduces this new level, which is referred to as out-of-process, since ASP runsoutside of the IIS process. In Medium isolation, all ASP applications configured to run as Medium share a singleprocess space. This reduces the number of processes required to run multiple out-of-process ASP applications onone box. Medium is the default isolation level in IIS 5.0.

    q

    High Isolation. Supported in IIS 4.0 and IIS 5.0, High isolation is also out-of-process. If ASP crashes, the Webserver doesn't. The ASP application is automatically restarted on the next ASP request. With High isolation, eachASP application that is configured to run as High runs in its own process space. This protects ASP applicationsfrom each other. Its drawback is that it requires a separate process for each ASP application. This can add up toa lot of overhead when dozens of applications need to be hosted on one box.

    q

    Which option is the best? In IIS 4.0, there was a fairly steep performance penalty for running out-of-process. In IIS 5.0,a lot of work was done to minimize the cost of running ASP applications out-of-process. In fact, in most tests, ASPout-of-process applications in IIS 5.0 run faster than in-process applications in IIS 4.0. Regardless, in-process (Low

    isolation level) still produces the best performance on both platforms. However, you won't see much benefit to the Lowisolation level if you have a relatively low hit rate or low maximum throughput. Therefore, you should not feel the needto reach for the Low isolation level until you need hundreds or thousands of pages per second per Web server. Asalways, test with multiple configurations and determine which trade-offs you are willing to make.

    Note When you run ASP applications out-of-process (Medium or High isolation), they run in MTS on NT4 and COM+ onWindows 2000. That is, on NT4 they run in Mtx.exe, and on Windows 2000, they run in DllHost.exe. You can see theseprocesses running in Task Manager. You can also see how IIS configures MTS Packages or COM+ Applications forout-of-process ASP applications.

    COM Options

    COM components also have three configuration options, though not completely analogous to the ASP options. COM

  • 8/7/2019 Microsoft's 25+ ASP Tips

    8/17

    components can be:"unconfigured," configured as Library Applications, or configured as Server Applications.Unconfigured means that the component is not registered with COM+. The component will run in the caller's processspace, that is, they are "in-process." Library Applications are also in-process, but benefit from COM+'s services,including security, transactions, and context support. Server Applications are configured to run in their own processspace.

    You may see a slight benefit of unconfigured components over Library Applications. You're likely to see a largeperformance benefit of Library Applications over Server Applications. This is because Library Applications run in the sameprocess as ASP, whereas Server Applications run in their own process. Inter-process calls are more expensive thanin-process calls. Also, when passing data such as recordsets between processes, all of the data must be copied betweenthe two processes.

    Pitfall! When using COM Server Applications, if you pass objects between ASP and COM, make sure that the objectsimplement "marshal-by-value," or MBV. Objects that implement MBV copy themselves from one process to another. Thisis better than the alternative, in which the object remains in the creator's process, and the other process calls repeatedlyinto the creating process to use the object. Disconnected ADO recordsets will marshal-by-value; connected recordsetswon't. The Scripting.Dictionary does not implement MBV and should not be passed between processes. Finally, amessage to VB programmers out there: MBV is NOT achieved by passing a parameter ByVal. MBV is implemented by theoriginal component author.

    What to Do?

    If we were to recommend configurations with reasonable trade-offs of performance versus reliability, they would be asfollows:

    On IIS 4.0, use ASP's Low Isolation level, and use MTS Server Packages.q

    On IIS 5.0, use ASP's Medium isolation level, and use COM+ Library Applications.q

    These are very general guidelines; hosting companies generally run ASP at Medium or High Isolation level, whereassingle-purpose Web servers can be run at Low isolation. Measure the trade-offs and decide for yourself whichconfiguration meets your needs.

    Tip 10: Use Option Explicit

    Use Option Explicit in your .asp files. This directive placed at the top of the .asp file forces the developer to declare avariables that will be used. Many programmers consider this helpful in debugging applications, as it avoids the chance ofmistyping a variable name and inadvertently creating new variables (for example, MyXLMString=... instead ofMyXMLString=).

    Perhaps more importantly, it turns out that declared variables are faster than undeclared variables. Under the covers,

    the scripting run time references undeclared variables by name, every time they are used. Declared variables, on theother hand, are assigned an ordinal, either at compile time or run time. Subsequently, declared variables are referencedby this ordinal. Since Option Explicit forces variable declaration, it insures that all variables are declared and thus willbe accessed quickly.

    Tip 11: Use Local Variables in Subroutines and Functions

    Local variables are those declared within subroutines and functions. Within a function or subroutine, local variable accessis faster than global variable access. Use of local variables also tends to make code cleaner, so use them when you can.

    Tip 12: Copy Frequently-Used Data to Script Variables

    When accessing COM objects in ASP, you should copy frequently-used object data to script variables. This will cut downon COM method calls, which are relatively expensive compared to accessing script variables. When accessing Collectionand Dictionary objects, this technique also cuts down on expensive lookups.

    In general, if you are going to access object data more than once, put that data into a script variable. Prime targets forthis optimization are Request variables (Form and QueryString variables). For example, your site may pass around aQueryString variable called UserID. Suppose this UserID is referenced a dozen times on a particular page. Instead ofcalling Request(?UserID?) a dozen times, assign the UserID to a variable at the top of the ASP page. Then use thatvariable throughout the page. This will save 11 COM method calls.

    In practice, accessing COM properties or methods can be deceptively expensive. Here is an example, showing somefairly common code (syntactically speaking):

    Foo.bar.blah.baz = Foo.bar.blah.qaz(1)If Foo.bar.blah.zaq = Foo.bar.blah.abc Then ' ...

  • 8/7/2019 Microsoft's 25+ ASP Tips

    9/17

    When this code runs, here's what happens:

    The variable Foo is resolved as a global object.1.

    The variable bar is resolved as a member ofFoo. This turns out to be a COM method call.2.

    The variable blah is resolved as a member ofFoo.bar. This, too, turns out to be a COM method call.3.

    The variable qaz is resolved as a member offoo.bar.blah. Yes, this turns out to be a COM method call.4.

    Invoke Foo.bar.blah.quaz(1). One more COM method call. Get the picture?5.

    Do steps 1 through 3 again to resolve baz. The system does not know if the call to qaz changed the objectmodel, so steps 1 through 3 must be done again to resolve baz.

    6.

    Resolve baz as a member ofFoo.bar.blah. Do the property put.7.

    Do steps 1 through 3 again and resolve zaq.8.

    Do steps 1 through 3 yet another time and resolve abc.9.

    As you can see, this is terribly inefficient (and slow). The fast way to write this code in VBScript is:

    Set myobj = Foo.bar.blah ' do the resolution of blah ONCEMyobj.baz = myobj.qaz(1)If Myobj.zaq = Myobj.abc Then '...

    If you're using VBScript 5.0 or later, you can write this using the With statement:

    With Foo.bar.blah.baz = .qaz(1)

    If .zaq = .abc Then '......End With

    Note that this tip also works with VB programming.

    Tip 13: Avoid Redimensioning Arrays

    Try to avoid Redim arrays. As far as performance is concerned, if you have a machine that is constrained by physicalmemory size, it's much better to set the initial dimension of the array to its worst-case scenarioor to set the dimensionto its optimal case and redim as necessary. This does not mean that you should just go out and allocate a couple ofmegabytes of memory if you know you aren't going to need it.

    The code below shows you gratuitous use ofDim and Redim.

  • 8/7/2019 Microsoft's 25+ ASP Tips

    10/17

    This line of code must be executed before any response data has been written to the browser (that is, before any HTMLappears in the ASP script and before any Cookies have been set using the Response.Cookies collection). In general, it isbest to turn response buffering on for an entire Application. This allows you to avoid the above line of code on everypage.

    Response.Flush

    One common complaint about response buffering is that users perceive ASP pages as being less responsive (eventhough the overall response time is improved) because they have to wait for the entire page to be generated before theystart to see anything. For long-running pages, you can turn response buffering off by setting Response.Buffer = FalseHowever, a better strategy is to utilize the Response.Flush method. This method flushes all HTML that has been paintedby ASP to the browser. For example, after painting 100 rows of a 1,000-row table, ASP can call Response.Flush to forcethe painted results to the browser; this allows the user to see the first 100 rows before the remaining rows are ready.This technique can give you the best of both worldsresponse buffering combined with the gradual presentation of datato the browser.

    (Note that in the above example of a 1,000-row table, many browsers won't start painting the table until they see theclosing tag. Check your targeted browsers for support. To get around this, try breaking the table into multipletables with less rows, and call Response.Flush after each table. Newer versions of Internet Explorer will paint tablesbefore they are fully downloaded, and will paint especially fast if you specify the table's column widths; this avoidsforcing Internet Explorer to calculate the column widths by measuring the width of the contents of every cell.)

    The other common complaint about response buffering is that it can use a lot of server memory when generating verylarge pages. Leaving aside the wisdom of generating large pages, this problem can also be addressed with judicious useofResponse.Flush.

    Tip 15: Batch Inline Script and Response.Write Statements

    The VBScript syntax writes the value of "expression" to the ASP output stream. If responsebuffering is not turned on, then each of these statements results in writing data to the browser over the network inmany small packets. This is slow. Also, interspersing small amounts of script and HTML causes switching between thescript engine and HTML, reducing performance. Thus, use the following tip: Replace closely-bunched inline expressionswith one call to Response.Write. For example, in the following sample, there is one write to the response stream perfield per row, and many switches between VBScript and HTML per row:

    This tip has a much bigger effect when response buffering is disabled. It's best to enable response buffering, and then

  • 8/7/2019 Microsoft's 25+ ASP Tips

    11/17

    see if batching Response.Write helps performance.

    (In this particular example, the nested loop that builds the body of the table (While Not rs.EOF...) can be replaced bya carefully constructed call to GetString.)

    Tip 16: Use Response.IsClientConnected Before Embarking on Long Trips

    If the user gets impatient, they may abandon your ASP page before you even start executing their request. If they clickRefresh or move to a different page on your server, you will have a new request sitting at the end of the ASP requestqueue and a disconnected request sitting in the middle of the queue. Often this happens when your server is under highload (so it has a long request queue, with correspondingly high response times) and this only makes the situation worse.

    There's no point executing an ASP page (especially a slow, heavyweight ASP page) if the user is no longer connected.You can check for this condition by using the Response.IsClientConnected property. If it returns False, you should calResponse.End and abandon the rest of the page. In fact, IIS 5.0 codifies this practicewhenever ASP is about toexecute a new request, it checks to see how long the request has been in the queue. If it has been there for more than 3seconds, ASP will check to see if the client is still connected and immediately terminate the request if it's not. You canuse the AspQueueConnectionTestTime setting in the metabase to adjust this timeout of 3 seconds.

    If you have a page that takes a very long time to execute, you may also want to check Response.IsClientConnected atintervals. When response buffering is enabled, it is a good idea to do Response.Flush at intervals to give the user theimpression that something is happening.

    Note On IIS 4.0, Response.IsClientConnected will not work correctly unless you first do a Response.Write. Ifbuffering is enabled, you'll also need to do a Response.Flush. On IIS 5.0, there is no need forthisResponse.IsClientConnected works fine. In any case, Response.IsClientConnected has some costs, so only useit before an operation that takes at least, say 500 milliseconds (that's a long time if you're trying to sustain a throughputof dozens of pages per second). As a general rule of thumb, don't call it in every iteration of a tight loop, such as whenpainting the rows of a tableperhaps every 20th or 50th row of the table, instead.

    Tip 17: Instantiate Objects Using the Tag

    If you need to refer to objects that might not be used in all code paths (especially Server- or Application-scopedobjects), declare them by using the tag in Global.asa rather than using theServer.CreateObject method. Server.CreateObject creates the object immediately. If you don't use that object later,you end up wasting resources. The tag declares objname, but objname isn't actually created untilthe first time that one of its methods or properties are used.

    This is another example of lazy evaluation.

    Tip 18: Use TypeLib Declarations for ADO and Other Components

    When using ADO, developers often include adovbs.txt to get access to ADO's various constants. This file must beincluded on every page that wants to use the constants. This constant file is fairly large, adding a lot of overhead toevery ASP page's compilation time and script size.

    IIS 5.0 introduces the ability to bind to a component's type library. This allows you to reference the type library once anduse it on every ASP page. Each page does not pay the penalty of compiling the constant file, and component developersdo not have to build VBScript #include files for use in ASP.

    To access the ADO TypeLib, place one of the following statements in Global.asa.

    or

    Tip 19: Take Advantage of Your Browser's Validation Abilities

    Modern browsers have advanced support for features such as XML, DHTML, Java applets, and the Remote Data Service.Take advantage of these features whenever you can. All of these technologies can save round trips to the Web server byperforming client-side validation as well as data caching. If you are running a smart browser, the browser is capable ofdoing some validation for you (for example, checking that a credit card has a valid checksum before executing POST).Again, take advantage of this whenever you can. By cutting down on client-server round trips, you'll reduce the stress on

  • 8/7/2019 Microsoft's 25+ ASP Tips

    12/17

    the Web server and cut down network traffic (though the initial page sent to the browser is likely to be larger), as well asany back-end resources that the server accesses. Furthermore, the user will not have to fetch new pages as often,improving the experience. This does not relieve you of the need to do server-side validationyou should always doserver-side validation as well. This protects against bad data coming from the client for some reason, such as hacking, obrowsers that don't run your client-side validation routines.

    Much has been made of creating "browser-independent" HTML. This concern often discourages the developer from takingadvantage of popular browser features that could benefit performance. For truly high-performance sites that must beconcerned about browser "reach," a good strategy is to optimize pages for the popular browsers. Browser features canbe easily detected in ASP using the Browser Capabilities Component. Tools such as Microsoft FrontPage can help youdesign code that works with the browsers and HTML versions you wish to target. See When is Better Worse? Weighingthe Technology Trade-Offs for further discussion.

    Tip 20: Avoid String Concatenation in Loops

    Many people build a string in a loop like this:

    s = ?? & vbCrLfFor Each fld in rs.Fieldss = s &? ? &fld.Name &? ?Next

    While Not rs.EOFs = s & vbCrLf &? ?For Each fld in rs.Fieldss = s &? ? &fld.Value &? ?Nexts = s &? ?

    rs.MoveNextWend

    s = s & vbCrLf &?? & vbCrLfResponse.Write s

    There are several problems with this approach. The first is that repeatedly concatenating a string takes quadratic time;less formally, the time that it takes to run this loop is proportional to the square of the number of records times thenumber of fields. A simpler example should make this clearer.

    s = ??For i = Asc(?A?) to Asc(?Z?)s = s &Chr(i)Next

    On the first iteration, you get a one-character string, ?A?. On the second iteration, VBScript has to reallocate the string

    and copy two characters (?AB?) into s. On the third iteration, it has to reallocate s again and copy three characters intos. On the Nth (26th) iteration, it has to reallocate and copy N characters into s. That's a total of 1+2+3+...+N which isN*(N+1)/2 copies.

    In the recordset example above, if there were 100 records and 5 fields, the inner loop would be executed 100*5 = 500times and the time taken to do all the copying and reallocation would be proportional to 500*500 = 250,000. That's a lotof copying for a modest-sized recordset.

    In this example, the code could be improved by replacing the string concatenation with Response.Write() or inlinescript (). If response buffering is turned on (as it should be), this will be fast, as Response.Writejust appends the data to the end of the response buffer. No reallocation is involved and it's very efficient.

    In the particular case of transforming an ADO recordset into an HTML table, consider using GetRows or GetString.

    If you concatenate strings in JScript, it is highly recommended that you use the += operator; that is, use s += ?somestring?, not s = s + ?some string?.

    Tip 21: Enable Browser and Proxy Caching

    By default, ASP disables caching in browsers and proxies. This makes sense since by nature an ASP page is dynamic withpotentially time-sensitive information. If you have a page that doesn't require a refresh on every view, you shouldenable browser and proxy caching. This allows browsers and proxies to use a "cached" copy of a page for a certainlength of time, which you can control. Caching can greatly alleviate load on your server and improve the userexperience.

    What kind of dynamic pages might be candidates for caching? Some examples are:

    A weather page, where the weather is only updated every 5 minutes.q

  • 8/7/2019 Microsoft's 25+ ASP Tips

    13/17

    A home page listing news items or press releases, which are updated twice a day.q

    A mutual fund performance listing, where underlying statistics are only updated every few hours.q

    Note that with browser or proxy caching, you'll get less hits recorded on your Web server. If you are trying to accuratelymeasure all page views, or post advertising, you may not be happy with browser and proxy caching.

    Browser caching is controlled by the HTTP "Expires" header, which is sent by a Web server to a browser. ASP providestwo simple mechanisms to send this header. To set the page to expire at a certain number of minutes in the future, setthe Response.Expires property. The following example tells the browser that the content expires in 10 minutes:

    Setting Response.Expires to a negative number or 0 disables caching. Be sure to use a large negative number, such as-1000 (a little more than a day), to work around mismatches between the clocks on the server and the browsers. Asecond property, Response.ExpiresAbsolute, allows you set the specific time at which the content will expire:

    Rather than using the Response object to set expiration, you can write a tag into the HTML, usually within the section of the HTML file. Some browsers will respect this directive, although proxies will not.

    Finally, you can indicate whether the content is valid for an HTTP proxy to cache, using the Response.CacheControlproperty. Setting this property to "Public" enables proxies to cache the content.

    By default, this property is set to "Private." Note that you should not enable proxy caching for pages that show dataspecific to a user, as the proxy may serve pages to users that belong to other users.

    Tip 22: Use Server.Transfer Instead of Response.Redirect Whenever Possible

    Response.Redirect tells the browser to request a different page. This function is often used to redirect the user to a logon or error page. Since a redirect forces a new page request, the result is that the browser has to make two round tripsto the Web server, and the Web server has to handle an extra request. IIS 5.0 introduces a new function,Server.Transfer, which transfers execution to a different ASP page on the same server. This avoids the extrabrowser-to-Web-server round trip, resulting in better overall system performance, as well as better response time forthe user. Check out New Directions in Redirection, which talks about Server.Transfer and Server.Execute.

    Also see Leveraging ASP in IIS 5.0 for a full list of the new features in IIS 5.0 and ASP 3.0.Tip 23: Use Trailing Slashes in Directory URLs

    A related tip is to make sure to use a trailing slash (/) in URLs that point to directories. If you omit the trailing slash, thebrowser will make a request to the server, only to be told that it's asking for a directory. The browser will then make asecond request with the slash appended to the URL, and only then will the server respond with the default document forthat directory, or a directory listing if there is no default document and directory browsing has been enabled. Appendingthe slash cuts out the first, futile round trip. For user-friendliness, you may want to omit the trailing slash in displaynames.

    For example, write:

    http://msdn.microsoft.com/workshop

    This also applies to URLs pointing to the home page on a Web site: Use the following: , not .

    Tip 24: Avoid Using Server Variables

    Accessing server variables causes your Web site to make a special request to the server and collect all server variables,not just the one that you requested. This is akin to needing to retrieve a specific item in a folder that you have in thatmusty attic of yours. When you want that one item, you have to go to the attic to get the folder first, before you canaccess the item. This is the same thing that happens when you request a server variablethe performance hit occursthe first time you request a server variable. Subsequent requests for other server variables do not cause performancehits.

  • 8/7/2019 Microsoft's 25+ ASP Tips

    14/17

    Never access the Request object unqualified (for example, Request("Data")). For items not in Request.Cookies,Request.Form, Request.QueryString, or Request.ClientCertificate, there is an implicit call toRequest.ServerVariables. The Request.ServerVariables collection is much slower than the other collections.

    Tip 25: Upgrade to the Latest and Greatest

    System components are constantly and we recommend that you upgrade to the latest and greatest. Best of all would beto upgrade to Windows 2000 (and hence, IIS 5.0, ADO 2.5, MSXML 2.5, Internet Explorer 5.0, VBScript 5.1, and JScript5.1). IIS 5.0 and ADO 2.5 implement spectacular performance gains on multiprocessor machines. Under Windows 2000,ASP scales nicely to four processors or more, whereas under IIS 4.0, ASP didn't scale well beyond two processors. The

    more script code and ADO usage in your application, the more performance benefits you'll see after upgrading toWindows 2000.

    If you can't upgrade to Windows 2000 just yet, you can upgrade to the latest releases of SQL Server, ADO, VBScript andJScript, MSXML, Internet Explorer, and NT 4 Service Packs. All of them offer improved performance as well as increasedreliability.

    Tip 26: Tune Your Web Server

    There are several IIS tuning parameters that can improve site performance. For example, with IIS 4.0, we've oftenfound that increasing the ASP ProcessorThreadMax parameter (see IIS documentation) can have significant benefits,especially on sites that tend to wait on back-end resources such as databases or other middle-ware products such asscreen-scrapers. In IIS 5.0, you may find that turning on ASP Thread Gating is more effective than trying to find anoptimal setting for AspProcessorThreadMax, as it is now known.

    For good references, see Tuning IIS below.

    The optimal configuration settings are going to be determined by (among other factors) your application code, thehardware it runs on, and the client workload. The only way to discover the optimal settings is to run performance tests,which brings us to the next tip.

    Tip 27: Do Performance Testing

    As we said before, performance is a feature. If you are trying to improve performance on a site, set a performance goal,then make incremental improvements until you reach your goal. Don't save all performance testing for the end of theproject. Often, at the end of a project, it's too late to make necessary architectural changes, and you disappoint yourcustomer. Make performance testing a part of your daily testing. Performance testing can be done against individualcomponents, such as ASP pages or COM objects, or on the site as a whole.

    Many people test the performance of their Web sites by using a single browser to request pages. This will give you agood feel for the responsiveness of the site, but it will tell you nothing about how well the site performs under load.

    Generally, to accurately measure performance, you need a dedicated testing environment. This environment shouldinclude hardware that somewhat resembles production hardware in terms of processor speed, number of processors,memory, disk, network configuration, and so on. Next, you need to define your client workload: how many simultaneoususers, the frequency of requests they will be making, the types of pages they'll be hitting, and so forth. If you don't haveaccess to realistic usage data from your site, you'll need to guesstimate. Finally, you need a tool that can simulate youranticipated client workloads. Armed with these tools, you can start to answer questions such as "How many servers will Ineed if I have N simultaneous users?" You can also sniff out bottlenecks and target these for optimization.

    Some good Web stress-testing tools are listed below. We highly recommend the Microsoft Web Application Stress (WAS)Toolkit. WAS allows you to record test scripts and then simulate hundreds or thousands of users hitting your Webservers. WAS reports numerous statistics, including requests per second, response time distributions, and error counts.WAS has both a rich-client and a Web-based interface; the Web interface allows you to run tests remotely.

    Be sure to read the IIS 5.0 Tuning Guide.

    Tip 28: Read the Resource Links

    Here are some links to some great resources related to performance. If you read anything, read Developing ScalableWeb Applications.

  • 8/7/2019 Microsoft's 25+ ASP Tips

    15/17

    Resources

    Optimizing ASP scripts Tuning IIS ADO and SQL Server

    ASP components and threading

    models

    Dictionary components Session state

    Performance and scalability Tools Books

    ASP Web sites ASP style XML

    Optimizing ASP scripts

    Developing Scalable Web Applicationsq

    Got Any Cache? by Nancy Winnick Clutsq

    Maximizing the Performance of Your Active Server Pages by Nancy Winnick Clutsq

    15 Seconds: Performance Sectionq

    Enhancing Performance in ASP - Part I by Wayne Plourdeq

    When is Better Worse? Weighing the Technology Trade-Offs by Nancy Winnick Clutsq

    Speed and Optimization Resources by Charles Carrollq

    Tuning IIS

    The Art and Science of Web Server Tuning with Internet Information Services 5.0q

    Leveraging ASP in IIS 5.0 by J.D. Meierq

    Tuning IIS 4.0 for High Volume Sites by Michael Stephensonq

    Tuning Internet Information Server Performance by Mike Mooreq

    Navigating the Maze of Settings for Web Server Performance Optimization by Todd Wankeq

    ADO and SQL Server

    Top Ten Tips: Accessing SQL Through ADO and ASP by J.D. Meierq

    Improve the Performance of your MDAC Application by Suresh Kannanq

    Pooling in the Microsoft Data Access Components by Leland Ahlbeck and Don Willitsq

    SQL Server: Performance Benchmarks and Guidesq

    Improving the Performance of Data Access Components with IIS 4.0 by Leland Ahlbeckq

    Microsoft Data Access Components (MDAC) and ActiveX Data Objects (ADO) Performance Tips by Leland Ahlbeckq

    Microsoft SQL Server 7.0 Practical Performance Tuning and Optimization - The Server Perspective by Damien

    Lindauer

    q

    Microsoft SQL Server 7.0 Practical Performance Tuning and Optimization - The Application Perspective by Damien

    Lindauer

    q

    Accessing Recordsets over the Internet by Dino Espositoq

    ASP components and threading models

    ASP Component Guidelines by J.D. Meierq

    Q243548: INFO: Design Guidelines for VB Components under ASPq

    Threading Models Explained by Nancy Winnick Clutsq

    http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/iisref/perf6o37.htmhttp://msdn.microsoft.com/workshop/server/feature/cache.asphttp://msdn.microsoft.com/workshop/server/asp/maxperf.asphttp://local.15seconds.com/focus/performance.htmhttp://www.asptoday.com/articles/20000113.htmhttp://msdn.microsoft.com/workshop/management/planning/tradeoff.asphttp://www.learnasp.com/learn/speedmore.asphttp://www.microsoft.com/windows2000/library/operations/web/tuning.asphttp://msdn.microsoft.com/workshop/server/asp/server02282000.asphttp://msdn.microsoft.com/workshop/server/feature/tune.asphttp://www.microsoft.com/isn/whitepapers/tuningiis.asphttp://www.microsoft.com/backstage/whitepaper.htmhttp://www.microsoft.com/mind/1198/ado/ado.htmhttp://msdn.microsoft.com/library/default.asp?URL=/library/psdk/dasdk/impr8l2m.htmhttp://msdn.microsoft.com/library/default.asp?URL=/library/techart/pooling2.htmhttp://www.microsoft.com/sql/productinfo/performance.htmhttp://msdn.microsoft.com/workshop/server/components/daciisperf.asphttp://www.microsoft.com/Seminar/1033/19991028DATALA1/Portal.htmhttp://www.microsoft.com/Seminar/1033/19991028TEPerfTun1/Portal.htmhttp://www.microsoft.com/Seminar/1033/19991028TEPerfTun2/Portal.htmhttp://msdn.microsoft.com/msdnmag/issues/0300/cutting/cutting.asphttp://msdn.microsoft.com/workshop/server/asp/server01242000.asphttp://www.microsoft.com/technet/support/kb.asp?ID=243548http://msdn.microsoft.com/workshop/essentials/geekspeak/geekthread.asphttp://msdn.microsoft.com/workshop/essentials/geekspeak/geekthread.asphttp://www.microsoft.com/technet/support/kb.asp?ID=243548http://msdn.microsoft.com/workshop/server/asp/server01242000.asphttp://msdn.microsoft.com/msdnmag/issues/0300/cutting/cutting.asphttp://www.microsoft.com/Seminar/1033/19991028TEPerfTun2/Portal.htmhttp://www.microsoft.com/Seminar/1033/19991028TEPerfTun1/Portal.htmhttp://www.microsoft.com/Seminar/1033/19991028DATALA1/Portal.htmhttp://msdn.microsoft.com/workshop/server/components/daciisperf.asphttp://www.microsoft.com/sql/productinfo/performance.htmhttp://msdn.microsoft.com/library/default.asp?URL=/library/techart/pooling2.htmhttp://msdn.microsoft.com/library/default.asp?URL=/library/psdk/dasdk/impr8l2m.htmhttp://www.microsoft.com/mind/1198/ado/ado.htmhttp://www.microsoft.com/backstage/whitepaper.htmhttp://www.microsoft.com/isn/whitepapers/tuningiis.asphttp://msdn.microsoft.com/workshop/server/feature/tune.asphttp://msdn.microsoft.com/workshop/server/asp/server02282000.asphttp://www.microsoft.com/windows2000/library/operations/web/tuning.asphttp://www.learnasp.com/learn/speedmore.asphttp://msdn.microsoft.com/workshop/management/planning/tradeoff.asphttp://www.asptoday.com/articles/20000113.htmhttp://local.15seconds.com/focus/performance.htmhttp://msdn.microsoft.com/workshop/server/asp/maxperf.asphttp://msdn.microsoft.com/workshop/server/feature/cache.asphttp://msdn.microsoft.com/library/default.asp?URL=/library/psdk/iisref/perf6o37.htm
  • 8/7/2019 Microsoft's 25+ ASP Tips

    16/17

    So Happy Together? Using ActiveX components with Active Server Pages by Nancy Winnick Clutsq

    Developing Active Server Components with ATL by George Reillyq

    Agility in Server Components by Neil Allainq

    Building High-Performance Middle-Tier Components with C++ by Jon Flandersq

    Active Server Pages and COM Apartments by Don Boxq

    House of COM: Active Server Pages by Don Boxq

    House of COM: Contexts by Don Boxq

    House of COM: Performance Trade-offs of the Windows 2000 Component Execution Environment by Don Boxq

    Building COM Components That Take Full Advantage of Visual Basic and Scripting by Ivo Salmreq

    Dictionary components

    Creating a Page Cache Object by Robert Coleridgeq

    Abridging the Dictionary Object: The ASP Team Creates a Lookup-Table Object by Robert Carterq

    Caprock Dictionaryq

    Site Server Commerce Edition includes a dictionary componentq

    Session state

    Q175167: HOWTO: Persisting Values Without Sessionsq

    Q157906: HOWTO: How To Maintain State Across Pages with VBScriptq

    XML-based Persistence Behaviors Fix Web Farm Headaches by Aaron Skonnardq

    House of COM: Stateless Programming by Don Boxq

    Performance and scalability

    Blueprint for Building Web Sites Using the Microsoft Windows DNA Platformq

    Server Performance and Scalability Killers by George Reillyq

    Microsoft Visual Studio Scalability Centerq

    Fitch & Mather Stocks 2000q

    Tuning the FMStocks Applicationq

    High-Performance Visual Basic Apps by Ken Spencerq

    Duwamish Books, Phase 4q

    Top Windows DNA Performance Mistakes and How to Prevent Them by Gary Geiger and Jon Pulsipherq

    Building from Static HTML to High-Performance Web-Farms by Shawn Biceq

    Tools

    Microsoft Web Application Stress Toolq

    I Cant Stress It Enough -- Load Test Your ASP Application by J.D. Meierq

    Windows DNA Performance Kitq

    Monitoring Events in Distributed Applications Using Visual Studio Analyzer by Mai-lan Tomsenq

    Books

    Professional Active Server Pages 3.0, Wrox Press. (Especially Chapter 26: Optimizing ASP Performance, by

    George Reilly and Matthew Gibbs)

    q

    Microsoft Internet Information Services 5.0 Resource Guide (bundled with Windows 2000 Server Resource Kit,q

    http://msdn.microsoft.com/workshop/components/activex/aspactx.asphttp://msdn.microsoft.com/workshop/c-frame.htm?/workshop/server/asp/comp.asphttp://msdn.microsoft.com/workshop/server/components/agility.asphttp://www.microsoft.com/Seminar/1033/19991118TEHighPerfJF1/Portal.htmhttp://www.develop.com/dbox/aspapt.asphttp://www.microsoft.com/msj/defaulttop.asp?page=/msj/0998/com0998top.htmhttp://www.microsoft.com/msj/defaulttop.asp?page=/msj/0999/com/com0999.htmhttp://msdn.microsoft.com/msdnmag/issues/0300/com/com.asphttp://msdn.microsoft.com/library/default.asp?URL=/library/techart/msdn_vbscriptcom.htmhttp://msdn.microsoft.com/library/default.asp?URL=/library/techart/d4cache.htmhttp://msdn.microsoft.com/workshop/management/planning/MSDNchronicles2.asphttp://www.caprockconsulting.com/software.asphttp://www.microsoft.com/siteserver/commerce/default.htmhttp://www.microsoft.com/technet/support/kb.asp?ID=175167http://www.microsoft.com/technet/support/kb.asp?ID=157906http://msdn.microsoft.com/msdnmag/issues/0300/XML/XML.asphttp://www.microsoft.com/msj/defaulttop.asp?page=/msj/0398/activex0398.htmhttp://msdn.microsoft.com/msdn-online/start/features/DNAblueprint.asphttp://msdn.microsoft.com/workshop/server/iis/tencom.asphttp://msdn.microsoft.com/vstudio/centers/scale/default.asphttp://msdn.microsoft.com/msdn-online/start/features/fm2kintro.asphttp://msdn.microsoft.com/vstudio/centers/scale/tuning.asphttp://www.microsoft.com/mind/0899/beyond/beyond0899.htmhttp://msdn.microsoft.com/library/default.asp?URL=/library/techart/d4root.htmhttp://msdn.microsoft.com/msdn-online/start/features/windnamistakes.asphttp://www.microsoft.com/Seminar/1033/Building_from_Static/Building_from_Static_HTML.htmhttp://webtool.rte.microsoft.com/http://msdn.microsoft.com/workshop/server/asp/server092799.asphttp://www.microsoft.com/com/resources/WinDNAperf.asphttp://www.microsoft.com/Mind/0699/analyzer/analyzer.htmhttp://www.wrox.com/Consumer/Store/Details.asp?ISBN=1861002610http://mspress.microsoft.com/books/1394.htmhttp://www.microsoft.com/isapi/gomscom.asp?Target=/technet/win2000/reskits.asphttp://www.microsoft.com/isapi/gomscom.asp?Target=/technet/win2000/reskits.asphttp://mspress.microsoft.com/books/1394.htmhttp://www.wrox.com/Consumer/Store/Details.asp?ISBN=1861002610http://www.microsoft.com/Mind/0699/analyzer/analyzer.htmhttp://www.microsoft.com/com/resources/WinDNAperf.asphttp://msdn.microsoft.com/workshop/server/asp/server092799.asphttp://webtool.rte.microsoft.com/http://www.microsoft.com/Seminar/1033/Building_from_Static/Building_from_Static_HTML.htmhttp://msdn.microsoft.com/msdn-online/start/features/windnamistakes.asphttp://msdn.microsoft.com/library/default.asp?URL=/library/techart/d4root.htmhttp://www.microsoft.com/mind/0899/beyond/beyond0899.htmhttp://msdn.microsoft.com/vstudio/centers/scale/tuning.asphttp://msdn.microsoft.com/msdn-online/start/features/fm2kintro.asphttp://msdn.microsoft.com/vstudio/centers/scale/default.asphttp://msdn.microsoft.com/workshop/server/iis/tencom.asphttp://msdn.microsoft.com/msdn-online/start/features/DNAblueprint.asphttp://www.microsoft.com/msj/defaulttop.asp?page=/msj/0398/activex0398.htmhttp://msdn.microsoft.com/msdnmag/issues/0300/XML/XML.asphttp://www.microsoft.com/technet/support/kb.asp?ID=157906http://www.microsoft.com/technet/support/kb.asp?ID=175167http://www.microsoft.com/siteserver/commerce/default.htmhttp://www.caprockconsulting.com/software.asphttp://msdn.microsoft.com/workshop/management/planning/MSDNchronicles2.asphttp://msdn.microsoft.com/library/default.asp?URL=/library/techart/d4cache.htmhttp://msdn.microsoft.com/library/default.asp?URL=/library/techart/msdn_vbscriptcom.htmhttp://msdn.microsoft.com/msdnmag/issues/0300/com/com.asphttp://www.microsoft.com/msj/defaulttop.asp?page=/msj/0999/com/com0999.htmhttp://www.microsoft.com/msj/defaulttop.asp?page=/msj/0998/com0998top.htmhttp://www.develop.com/dbox/aspapt.asphttp://www.microsoft.com/Seminar/1033/19991118TEHighPerfJF1/Portal.htmhttp://msdn.microsoft.com/workshop/server/components/agility.asphttp://msdn.microsoft.com/workshop/c-frame.htm?/workshop/server/asp/comp.asphttp://msdn.microsoft.com/workshop/components/activex/aspactx.asp
  • 8/7/2019 Microsoft's 25+ ASP Tips

    17/17

    Microsoft Press.

    Microsoft Internet Information Server Resource Kit (for IIS 4.0), Microsoft Press.q

    Programming Distributed Applications with COM and Microsoft Visual Basic 6.0 by Ted Pattison, Microsoft Press.q

    Effective COM by Don Box, Keith Brown, Tim Ewald, and Chris Sells; Addison-Wesley.q

    Developing Web Usability: The Practice of Simplicity by Jakob Nielsen, New Riders.q

    ASP Web sites

    Microsoft TechNet for IISq

    LearnASP.comq

    4GuysFromRolla.comq

    15Seconds.comq

    AspToday.comq

    Asp101.comq

    AspLists.com. Many specialized mailing lists including:

    Fast Code!q

    ASP Advancedq

    Not Newbieq

    State Managementq

    Scalabilityq

    Visual Basic Componentsq

    XMLq

    C++/ATL Component Buildingq

    q

    UseIt.com: Web Usabilityq

    ASP style

    ASP Best Practices by George Reillyq

    ASP Quick Lessons by Charles Carrollq

    Planning for ASP by John Meadeq

    ASP Guidelines by J.D. Meierq

    XML

    Inside XML Performance by Chris Lovettq

    Inside MSXML3 Performance by Chris Lovettq

    Last updated May 11, 2000 2000 Microsoft Corporation. All rights reserved. Terms of use.

    http://mspress.microsoft.com/books/1398.htmhttp://mspress.microsoft.com/books/2137.htmhttp://www.develop.com/effectivecom/http://www.useit.com/jakob/webusability/http://www.microsoft.com/technet/iis/default.asphttp://www.learnasp.com/http://www.4guysfromrolla.com/http://www.15seconds.com/http://www.asptoday.com/http://www.asp101.com/http://www.asplists.com/asplists/http://www.asplists.com/asplists/aspfastcode.asphttp://www.asplists.com/asplists/aspadvanced2.asphttp://www.asplists.com/asplists/aspnotnewbie.asphttp://www.asplists.com/asplists/aspstatemanagement.asphttp://www.asplists.com/asplists/aspscalability.asphttp://www.asplists.com/asplists/aspvbcomponents.asphttp://www.asplists.com/asplists/aspxml.asphttp://www.asplists.com/asplists/asplowlevelcomponents.asphttp://www.useit.com/http://support.microsoft.com/support/activeserver/AspBestPractices.ppthttp://www.learnasp.com/learn/http://www.microsoft.com/technet/iis/planasp.asphttp://msdn.microsoft.com/workshop/server/asp/server122799.asphttp://msdn.microsoft.com/xml/articles/xml02212000.asphttp://msdn.microsoft.com/xml/articles/xml03202000.asphttp://www.microsoft.com/misc/cpyright.htmhttp://www.microsoft.com/misc/cpyright.htmhttp://msdn.microsoft.com/xml/articles/xml03202000.asphttp://msdn.microsoft.com/xml/articles/xml02212000.asphttp://msdn.microsoft.com/workshop/server/asp/server122799.asphttp://www.microsoft.com/technet/iis/planasp.asphttp://www.learnasp.com/learn/http://support.microsoft.com/support/activeserver/AspBestPractices.ppthttp://www.useit.com/http://www.asplists.com/asplists/asplowlevelcomponents.asphttp://www.asplists.com/asplists/aspxml.asphttp://www.asplists.com/asplists/aspvbcomponents.asphttp://www.asplists.com/asplists/aspscalability.asphttp://www.asplists.com/asplists/aspstatemanagement.asphttp://www.asplists.com/asplists/aspnotnewbie.asphttp://www.asplists.com/asplists/aspadvanced2.asphttp://www.asplists.com/asplists/aspfastcode.asphttp://www.asplists.com/asplists/http://www.asp101.com/http://www.asptoday.com/http://www.15seconds.com/http://www.4guysfromrolla.com/http://www.learnasp.com/http://www.microsoft.com/technet/iis/default.asphttp://www.useit.com/jakob/webusability/http://www.develop.com/effectivecom/http://mspress.microsoft.com/books/2137.htmhttp://mspress.microsoft.com/books/1398.htm