Chapter 10 Achieving Optimum Performance with PowerDynamo
To achieve optimum performance, it is crucial that you understand how the document cache works with your PowerDynamo Web site.
The document cache stores document source and output, for a duration of time, to minimize unnecessary processing of that document.
Figure 10-3 demonstrates a dynamic PowerDynamo Web document from a database-hosted Web site.
Once a request for a document has been made, three basic paths are possible. They are listed here in order of the most to the least efficient:
The most efficient path is requests for documents that have been written in such a way as to support cached output.
For more information about writing documents with cacheable output, see "Writing cacheable documents".
All documents that are executed in a PowerDynamo Web site have their source (and optionally their output) stored in the cache. This ensures that subsequent requests for the same data can be readily processed without the original expenditure of processing time to create connections, retrieve the source and execute the script. You set the storage size in Sybase Central.
The specified cache size determines the number (size) of documents that can be stored in the cache before the least recently requested documents begin to be released to make room for more recently requested documents.
The result of caching documents greatly reduces the processing time for repeated requests for a document. For this reason, the more documents that can reside in the cache at any one time the better.
Setting the cache size
Do not set your document cache size
higher than your machine's available memory.
To set the document cache size:
CachedOutputTimeOut is a property of the DynaScript document object that sets the duration of time for which the generated output of a document will be cached.
Setting a cachedOutputTimeOut value in a document allows the Web author to store the generated output of the document, after execution, for a predetermined amount of time. If a second request is then made to the same script within the allocated amount of time, the output in the cache is returned without execution of the document being required. This is much more efficient than the document executing again and possibly repeating the same database calls that were just made.
The following example sets a cachedOutputTimeOut of three minutes for the document:
<!--SCRIPT
document.WriteLn( "This is my output that will be cached for 3 minutes." );
document.cachedOutputTimeOut = 3;
-->
or you can use the Dynamo tag method:
<!--DOCUMENT CACHED_OUTPUT_TIMEOUT = 3 -->
When you set a cachedOutputTimeOut value, ensure that you are not compromising the validity of your Web site to increase performance. For example, while storing output for an extended period of time increases the performance of your Web site, it may also diminish accuracy if you store the generated output for too long. You should ensure output is regenerated with a frequency that is appropriate for the Web site data.
There are two pieces of information that can be stored in the document cache for each Web document.
The output of documents without a cachedOutputTimeOut value must still be generated but the source is available without a call to the database or file system. Documents that have a cachedOutputTimeOut value specified have their output stored in the cache as well as the source.
When it is possible, you should create documents with cachedOutputTimeOut values.
The size of the document cache may affect how documents with specified cachedOutputTimeOut values are cached.
If a document has a cachedOutputTimeOut value of 10 minutes, it will remain in the cache for the full 10 minutes only if there is room for it along with the subsequent documents that are called during those 10 minutes. When the cache is full and a new document is requested, the document that was least recently used is flushed to make room for the new document regardless of how long the cachedOutputTimeOut value is set to.
Cache is flushed
The entire document cache is flushed
if you modify or create documents outside a Web server environment;
for example, in Sybase Central.
Copyright © 1999 Sybase, Inc. All rights reserved. |