+ All Categories
Home > Technology > Maximizing application performance

Maximizing application performance

Date post: 19-Jan-2015
Category:
Upload: dominion
View: 465 times
Download: 2 times
Share this document with a friend
Description:
 
Popular Tags:
43
Transcript
Page 1: Maximizing application performance
Page 2: Maximizing application performance

© Copyright 2001 Lotus Development Corporation. All rights reserved. Printed in the UnitedStates.

Lotus and Lotus Notes are registered trademarks, and Domino is a trademark of LotusDevelopment Corporation. Other product and brand names may be trademarks of their respective companies.

Page 3: Maximizing application performance

Contents

31Appendix C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

30Appendix B: Resources for additional information . . . . . . . . . . . . . . . . . . . . . . . . . . .

29Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

29Appendix A: Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

28Hardware recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

25Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

23Is your server doing unnecessary work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

23Is your server being overloaded? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

23Tuning Servers for Maximum Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13How to program applications for maximum performance . . . . . . . . . . . . . . . . . .

12How to design views for maximum performance . . . . . . . . . . . . . . . . . . . . . . . . .

8How to design forms for maximum performance . . . . . . . . . . . . . . . . . . . . . . . . . .

7How to lay out pages for maximum performance . . . . . . . . . . . . . . . . . . . . . . . . . .

5Server Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3How to design applications for maximum performance . . . . . . . . . . . . . . . . . . . . .

3Tuning Applications for Maximum Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Note
Please note that the page numbers listed in the Table of Contents refer to the page numbers that appear in the footers of the printed documentation. To navigate to a specific page, select the chapter and use the scroll buttons in the tool bar to go to the page.
Page 4: Maximizing application performance
Page 5: Maximizing application performance

Introduction

Domino™ provides many ways to build dynamic Web sites and applications. Navigators,layout regions, programmable fields, and hide-when formulas give developers a wealthof options for building complex Web pages that are dynamically generated. However, asthe complexity of a Web application increases, the processing and calculation requiredby the server increases, which can affect performance. In addition, Domino providesmany services and functions as a Web application server, from replication to e-mail toclustering. As the demands on a server increase, the increased processing load canfurther compromise overall performance.

Performance tuning is an artSince every server and application is different, the answer to the question, “How can Imake my Domino application run faster?” varies. There is no single means of maximizing the performance of a Domino Web application or server, and no magic setting like GO_FASTER = 1 that you can put in your NOTES.INI. The Dominoserver performs so many functions that individual analysis of each server and application is required to tune it appropriately. While Lotus® has manyrecommendations and suggestions for maximizing performance — as detailed in thiswhite paper — fundamentally, it is the engineering skills of the Web developer,webmaster, and server administrator that can best tune each application and server toachieve optimum performance.

Tradeoffs are sometimes necessaryMaximum performance of an application does not always leave room for maximumdesign elegance or maintainability. Developers often have to make tradeoffs betweenspeed and beauty. A page with 15 beautiful 256-color graphics is slower to load than asimple page with one graphic. This means that Web developers must balance the needfor clean, simple functionality with the need for speed and make trade-offs wherenecessary. It is important you consider all of the suggestions in this white paper in thecontext of your individual application and design goals to reach optimum performance.

This white paper focuses on maximizing performanceThis white paper focuses on what you can do to maximize the performance of Domino interms of:

Z Web applications, from the application development perspective

Z Overall server performance, from the server administration perspective

We start at the high level, providing performance considerations from the architecturalperspective, with a straightforward explanation of “what to do” and “why.” We thenprogressively drill down into finer levels of detail, providing performance suggestionsfor application developers at the form, column, and field level of your Domino Webpages and for server administrators at the configuration and NOTES.INI level of yourDomino server.

Lotus Development Corporation Maximizing Application and Server Performance in Domino 1

Page 6: Maximizing application performance

This white paper is intended to be the central source of Domino performance tuningsuggestions from Lotus, and contains information compiled from many sources.References to those and additional resources of performance information are located inAppendix B.

The information here applies to 4.x versions of Domino, except where noted. Note that in Domino 5.0, some NOTES.INI settings will be moved into and accessedthrough the Domino directory. Every new release of Domino contains numerousperformance enhancements; note that the easiest solution may be to upgrade your Domino server to the latest version for maximum performance.

2 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 7: Maximizing application performance

Tuning Applications for Maximum Performance

How to design applications for maximum performanceThe first step in examining or building a Web application is designing the architecture.How many pages, views, and databases are involved? The table below containssuggestions that should be considered at this architectural level. Many of the suggestionsrevolve around a couple of major themes:

Z Indexing views takes time and processing power

Z Cached data is served faster than non-cached data

Note that some of these suggestions, although they directly affect applicationperformance, are often handled by the server administrator instead of the applicationdeveloper.

Continued

Consider putting secure informa-tion in a separate database forthose users that need it, instead ofthe main database that receivesheavy traffic. See Appendix A formore information about commandcaching.

Authentication takes time. Dominomust look up names in the direc-tory, plus, certain commands areonly cached when requestedanonymously. See the “Why”section in the next row below foradditional effects of authentication.

Minimize or eliminateauthentication in busydatabases.

See Appendix A for more informa-tion about caching in versions4.6.1 and higher.

Pages are served faster if they arealready in the cache. Dominoflushes the command cache if thedatabase file is modified, such asthrough the creation of newdocuments.

Minimize the creationof documents in busydatabases.

For example, hidden views usedfor keyword lookups do not changevery often but are still indexedregularly based on the defaultsettings. You can change the viewrefresh interval through theRefresh Index option in Viewproperties, Advanced options.

Indexing views takes time andprocessing power; refresh viewsless often to reduce the load onthe system.

Refresh indexesinfrequently.

Views and folders, also known asindexes, must be refreshed toremain current. The more viewsyou have, the more work isrequired by the server to refreshthese views.

Minimize the numberof views and folders.

DetailsWhyWhat to do

Lotus Development Corporation Maximizing Application and Server Performance in Domino 3

Page 8: Maximizing application performance

This suggestion does not apply toreleases 4.5.1 and higher.

Prior to Domino 4.5, script librariesused to result in somewhat slowerapplication performance.

Minimize the use ofscript libraries (4.5 orearlier)

Typically, you should only need toopen a database or a documentonce in a script. Opening databaseelements repeatedly is redundantand will be time consuming.

Minimize databaseaccesses in scriptsand formulas.

This is often performed by theUPDALL task, which is configuredby the server administrator.

Compacting databases purgesdeletion stubs. Compact yourapplication databases regularlyduring development (manualcompact) and production (UPDALLtask).

Compact databasesregularly.

For example, if you have a catalogpage that does not changefrequently, run a scheduled agenthourly or at night to update thecontents of the page rather thanuse formulas to recalculate fieldseach time a user requests thepage.

Performing calculations usingscheduled agents instead ofdynamic events can achievesignificant performance gains byreducing the number of times apage must be dynamically gener-ated.

Use scheduledagents for offlinecalculations.

SSL can be configured at theserver level, in the Domino Direc-tory, as well as in the Databaseproperties option “Web Access:Require SSL Connection” (4.6).

A test case of Notes port encryp-tion on mail messages showed aperformance decrease of 5–10%.The impact could be largerdepending on your application.

SSL encrypted transactions slowserver performance. Choose SSLonly when a high degree ofsecurity is essential.

Use Secure SocketsLayer (SSL) onlywhen absolutelynecessary

Consider using aseparate SSL-onlydatabase for secureinformation

The “Maximum cachedcommands” setting in the Serverdocument specifies how manycommands it stores; the default is128. See Appendix A for moreinformation about caching inversions 4.6.1 and higher.

Domino caches the commands ituses to display pages to anony-mous users. When a registeredWeb user is prompted for a nameand password, Domino does notcache the commands for thatsession.

Setting an application’s defaultaccess to access levels other thananonymous will require Domino toauthenticate users and thereforenot cache commands.

Use Anonymous forDefault access whenpossible.

DetailsWhyWhat to do

4 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 9: Maximizing application performance

Server Configuration

Continued

In the HTTP Server section of theServer document, change thesettings in these fields to adjustthe server’s memory cache:

• Maximum cached commands

• Maximum cached databasedesigns

• Maximum cached users

To optimize response time,Domino caches information aboutHTTP commands, databases, andusers. Using these caches canalleviate the time it takes to mappages and authenticate users.

Increase memorycache for HTTPcommands, databasedesigns, and users.

In the HTTP Server section of theServer document, change thesettings in the following fields:

• Cache directory

• Garbage collection

• Garbage collection interval

• Maximum cache size

• Delete cache on shutdown

To optimize response time,Domino stores image files and fileattachments in the file cachedirectory named domino\cache (bydefault). Since converting bitmapimages to Web image formats cantake time, caching the convertedfiles on disk allows Domino toreturn inline images more quickly.However, creating a cache that isgigantic can lock up systemresources; be conservative.

Slightly increase diskcache for images andattachments.

Put the following setting into theserver’s NOTES.INI file:

DominoAnalyzeFormulas=1

For more information on thisfeature, see Appendix A. Thissetting will be set to 1 by default inDomino 5.0.

By default, Domino will not allowany dynamic pages that containformulas to be cached, since theresulting values could quicklybecome outdated. However, youcan configure Domino to do intelli-gent caching based on the volatil-ity of the formulas used.

Enable caching ofdynamic pages.

Put the following setting on oneline into the server’s NOTES.INIfile:

DominoAsynchronizeAgents=1

Make sure that your applicationdesign accommodates agentsrunning in parallel.

By default, Domino will executeagents triggered by web browsersone at a time (serially). ConfiguringDomino to run agents in parallelmay improve your applicationresponse time.

Run web-triggeredagents in parallel.

DetailsWhyWhat to do

Lotus Development Corporation Maximizing Application and Server Performance in Domino 5

Page 10: Maximizing application performance

Increase the setting for theNSF_BUFFER_POOL_SIZEvariable in the NOTES.INI file.This setting determines themaximum size of the cache forstoring views (in bytes). It can beincreased to up to ¼ the physicalmemory for large views or manyviews. We don’t recommendincreasing it beyond ¼ the physi-cal memory of the server. See the“Does it take a long time to displayviews?” section for moreinformation.

Large views take longer to display.Caching these views in a largerview buffer will speedperformance, instead of forcingthe server to read the view fromdisk.

Increase view bufferon server.

DetailsWhyWhat to do

6 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 11: Maximizing application performance

How to lay out pages for maximum performanceDomino provides many ways to lay out pages, using both HTML and Domino databaseconstructs such as forms and fields. This section focuses on approaches to laying out theappearance of a page using static elements. The next section summarizes ways to designforms for maximum performance.

Continued

If you are upgrading a Domino 4.xapplication, you will need tore-insert the graphics in order forthem to be stored in their nativeformat. However, keep in mind thatthose graphics would not be ableto be viewed from a Notes™ 4.xclient.

Domino 5.0 stores graphics in theirnative image format (i.e. GIF,JPEG), which greatly improvesperformance. In previous releases,images were converted to bitmapswhen stored in a Dominodatabase, which required conver-sion back to GIF format whenthose bitmaps were delivered tothe Web. In 5.0, no conversionoccurs when a graphic is alreadystored in its native format, greatlyreducing overhead.

Store graphics in theirnative format (R5only).

Limit bitmap graphics to 16 colorsand use low-resolution (72 dpi)images for smaller files and betterperformance across multipleplatforms.

If you use 256-color bitmaps, useno more than one per form anduse the Lotus color palette tocreate the bitmap.

The more colors you use, thelarger the size of the graphic, andthe more time required to transmitthe page.

Minimize the use of256-color bitmaps.

Keep image file sizesas small as possible.

Note that you must generatevalues for the values that Dominowould otherwise calculate, such asauthor and creation date, becauseDomino passes the document tothe browser without anypre-computing or other Domino-generated data.

When Domino encounters a pagethat contains a field named“HTML,” Domino reads the valueof the HTML field and sends thedata to the browser withoutperforming any computations.Therefore, it is the fastest way todisplay Web pages. The HTMLfield produces results that aresimilar to the form property “ForWeb Access: Treat documents asHTML,” but gives betterperformance.

Use the “HTML” field.

DetailsWhyWhat to do

Lotus Development Corporation Maximizing Application and Server Performance in Domino 7

Page 12: Maximizing application performance

1. Create a view to list theimages.

2. Then, use passthru HTML andURL commands to open adocument from a view by thekey name.

3. Open the image which is anattachment in that document.

The tag below displays the imagein the “Animation” view using thekey “gifs” in a different databaseon the same server.

<IMGSRC="/webimage.nsf/animation/gifs/$file/flag.gif">

This configuration causes Dominoto cache images, so performanceis better than imported or pastedimages for frequently used pages.

This configuration also usesserver disk space more efficientlythan imported or pasted imagesbecause one image can be usedmore than once.

Store images in agraphics librarydatabase as attach-ments in documents.

Use passthru HTML to access theimage using syntax such as <IMGSRC="banner.gif">. Images mustbe maintained on every server thatuses the images.

Caches images, so performance isbetter than imported or pastedimages for frequently used pages.Uses server disk space moreefficiently than imported or pastedimages because one image can beused more than once.

Store images inserver’s file system(4.6 or earlier only).

DetailsWhyWhat to do

How to design forms for maximum performanceDynamic pages in Domino are usually produced using forms. Forms provide the abilityto programmatically calculate content at many different levels, right down to individualparagraphs and fields. The suggestions below focus on ways to design forms formaximum performance. These suggestions embody some general themes that will helpguide you in designing your forms for maximum performance:

Z The more calculation required (through formulas, subforms, etc.) the slower the page

Z Cached data is served faster than non-cached data

8 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 13: Maximizing application performance

Continued

Architecturally, subforms are verysimilar to shared fields. Seeabove.

Loading subforms requires calcu-lations which can slow theopening of documents slightly.

Minimize the use ofsubforms.

Architecturally, shared fields areon a different note and Dominomust make extra internal functioncalls (a NoteOpen) to get thevalue of the shared field. OneNoteOpen call to get thedocument, one to get the form andone to get each of the sharedfields.

Shared fields open slightly slowerthan single-use fields.

Minimize the use ofshared fields.

After your design is complete, be sure to remove any blank,unused fields.

Each field is calculated when adocument is opened, refreshed, orsaved.

Minimize the numberof fields.

This causes Domino to search forany and all CGI environmentvariables in a page, which slowsperformance.

Domino assumes that “HTTP_”indicates a CGI environmentvariable.

Don’t use field namesthat start with“HTTP_”.

JavaScript is commonly used forfield input validation (e.g. Did theuser enter the date in the appropri-ate format?). This is more efficientthan using Domino’s field-basedinput validation which requires around-trip to the server.

JavaScript is evaluated on theclient, as opposed to formulas orscripts that are evaluated on theserver. This lightens the serverload and can increaseperformance.

Use JavaScript.

See Appendix A for details oncaching in Domino.

Some functions, depending on thecurrency of their data, are notcached.

Use cache-ableformulas on popularpages.

Complex formulas and those thatuse @DbLookup and @DbColumnrequire more processing time.

Simplify formulas.

See the Alternatives to usingformulas section below.

Each formula Domino must calcu-late when opening a page slowsyour application down.

Also, when an @function exists on a page (that is, on a form,document, view, or navigator), by default Domino doesn’t cachethe commands used to display the page.

Minimize the use offormulas.

DetailsWhyWhat to do

Lotus Development Corporation Maximizing Application and Server Performance in Domino 9

Page 14: Maximizing application performance

See the Redirection URLs sectionbelow.

When specifying a result page in a$$Return field or a WebQue-rySave agent, use double brack-ets around the URL (if the page ison the same server) for fasterperformance.

Use double bracketsaround redirectionURL’s.

For example, if you have twocomputed fields whose values aresupplied by a potentially slowformula such as @DbColumn, useone computed-for-display field tocollect the data, and compute theother fields from the computed-for-display field.

Computed fields require additionalprocessing and can slowperformance.

Minimize the numberof computed fields.

DetailsWhyWhat to do

Redirection URLsWhen a $$Return field or a WebQuerySave agent generates a URL to display the nextpage, the sequence of events is:

1. The browser submits the HTML form to the Domino server.

2. The server evaluates the $$Return formula or runs the WebQuerySave agent toproduce the redirection URL — for example, “[mydb.nsf/view?OpenView]”.

3. The server sends the redirection URL back to the browser.

4. The browser accepts that URL as input and requests the URL from the server.

5. The URL goes back to the server to process the request.

6. The server sends the result of that request back to the browser.

The process described above involves two round trips from the browser to the server. Ifthe redirection URL references a database on the same Domino server, you can avoid theextra trip back to the server (and therefore increase response time) by using doublebrackets “[[ ]]” around the URL.

The server recognizes this as an internal redirection URL and the transaction sequencebecomes:

1. The browser submits the HTML form to the Domino server.

2. The server evaluates the $$Return formula or runs the WebQuerySave agent toproduce an internal redirection URL — for example,“[[mydb.nsf/view?OpenView]]”.

3. Before sending the URL back to the browser, the server recognizes the URL asan internal redirection URL, evaluates the request, and sends the results of thatrequest back to the browser.

10 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 15: Maximizing application performance

Alternatives to using formulas

Use profile documents to store specific information across adatabase. For example, the Release 4.6 mail templates(mail46.ntf and mailc46.ntf) use profile documents to collectcalendar and schedule information, such as when a user will beout of the office and who can access the user’s mail file. Profiledocuments are useful for storing user-specific information in adatabase.

Lookup formulas

Formulas in form events where appropriate. This enables you toeasily control which formulas are calculated at which event, suchas formulas that should only execute when a form is opened orclosed. Field formulas are calculated whenever the page isrefreshed, saved, or opened, etc.

Field formulas

• A computed subform.

• A hide-when condition property such as “Hide when editing” or“Hide when reading.”

• Create two different versions of a form.

If you have Web-only or Notes-only forms (or other designelements like views and navigators), use the Design Propertiesbox to hide them from the inappropriate audience. Give bothdesign elements the same alias name so you can use that aliasname in formulas. For example, if you create views named Notes-Main and WebMain and assign them each the alias “Main,” you can use the alias name in a formula, such as@Command([OpenView]; “Main”). Domino presents the NotesMain view to a Notes client, and presents the WebMainview to a browser client. This technique gives better performancethan multiple hide-when conditions or computed subforms.

Hide-when formulas

JavaScript. JavaScript runs in the browser, reducing server load.Formulas

For maximum performance, use…Instead of…

Lotus Development Corporation Maximizing Application and Server Performance in Domino 11

Page 16: Maximizing application performance

How to design views for maximum performanceMany of the suggestions below revolve around a few major themes:

Z Indexing views takes time and processing power

Z Smaller views are faster views

Z The more calculation required, the slower the page

Z Cached data is served faster than non-cached data

When a document appears inmultiple categories, the size of theview index increases, causing theview to open and refresh moreslowly.

Do not allowdocuments to appearin multiple categories.

Using scheduled agents to updatethe view might be an alternative toprovide the same functionalitywhile improving view responsetime.

Time-sensitive formulas recalcu-late each time a Web user worksin the view — for example, when aWeb user opens, scrolls,collapses, or expands the view.

Avoid time-sensitivecolumn formulas thatuse @functions suchas @Now, @Created,and @Modified.

Use computed subforms instead.Due to the architecture of Domino,computed subforms are faster.

Do not use Formformulas.

Cascading views requires thescreen page to be redrawn oneach mouse click.

Minimize the use ofcascading views.

After your design is complete, besure to remove any blank, unusedor unnecessary columns.

Each column is calculated when aview is opened or refreshed.Smaller views are faster views.

Remove all unneces-sary columns.

Instead, place the formula on aform, and store its result in a fieldto be displayed in the column.

Write lookup formulas so that theformula calculates only when thefield calculates. For example:

@If(@IsDocBeingLoaded;

@Unavailable; @DBColumn())

Each formula Domino must calcu-late when opening a page slowsyour application down. @DB*lookup formulas are particularlytaxing.

Minimize the use offormulas in columns.

DetailsWhyWhat to do

12 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 17: Maximizing application performance

How to program applications for maximum performanceFormulas, LotusScript®, and Java represent just a few of the ways you can program yourWeb applications using Domino. Below are ways you can maximize the performance ofyour applications that use formulas and LotusScript.

Formulas

This applies to processingsmall groups of documents(i.e. less than 15 percent ofall documents in thedatabase).

Use LotusScript GetView, Search,and FTSearch methods instead offormulas.

Set the temporary variableonce, and then refer to thevariable for the rest of theformula.

Fewer calculationsprovides betterperformance.

Avoid redundant lookups in aformula by setting a temporaryvariable for a returned value.

Write the lookup formula toparse the returned data intothe appropriate fields.

Speed up multiple-value lookupsby creating a lookup view thatcombines all the needed values inone column.

Two ways to minimize thedata in the view is to usesubstrings or to concatenatestrings in one column.

Smaller views are fasterviews.

Perform lookups on hidden viewsthat have a minimum amount ofdata.

Cached data is servedfaster than non-cacheddata.

Use the Cache argumentwhenever possible when usinglookup formulas @DbColumn,@DbCommand, and @DbLookup.

The tradeoff in referring tocolumn numbers is that it isharder to maintain; anychange to the order ofcolumns in a view can causemiscalculations in yourformulas.

When you use a columnname, Domino mustcompare the string yourequest against the list ofall column names, which isslower than going directlyto the column specified bythe column number.

Use column numbers instead offield names when using@DbColumn or @DbLookup.

Another alternative for thisfunctionality is to use the fieldand text checkbox propertiesHide From Notes and HideFrom Web Browser.

It’s a simpler calculation,and thus faster.

Use @ClientType instead of@UserRoles (4.6 or higher).

DetailsWhyWhat to do

Lotus Development Corporation Maximizing Application and Server Performance in Domino 13

Page 18: Maximizing application performance

LotusScript

Continued

Forall is 75 percent faster than Forwhen referencing all elements in a1-dimensional array, and 50 percentfaster when referencing elements ina 2-dimensional array. Similarperformance improvements occur inarrays with higher numbers ofdimensions.

Forall loops are faster inhandling arrays than Forloops.

Use Forall instead of Forin referencing arrayelements.

In the following example, the firstfragment runs 60 percent faster thanthe second fragment.

Fragment A

For y=1 to 15000

z=z+1

Next

Fragment B

Do

z=z+1

y=y+1

Loop While y<= 15000

For loops are faster than Doloops, because the conditionthat bounds the Do loop mustbe evaluated at each iterationof the loop.

Use For loops instead ofDo loops.

For example, avoid using the front-end NotesUIDocument class to do many field updates. The back-end NotesDocument class is muchfaster and allows you to assign datatypes (including rich text) and to add new (hidden) fields. The front-end class allows you to update onlyfields that already exist on the form, and it allows you to insert only text in the field, as@Command([EditInsertText]) does.

Back-end classes do notneed to manage or processUI effects, and thus are fasterthan the front-end classes.

Use back-end classesinstead of front-endclasses.

DetailsWhyWhat to do

14 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 19: Maximizing application performance

Continued

Regular division, using theforward slash (/), alwaysreturns a float, even ifoperands are integers. Use abackslash (\) for integerdivision where you do notneed or want a floating pointresult.

Use a backslash (\) forinteger division insteadof a forward slash (/).

The ColumnValues property returnsan array of that document’s columnvalues in the document’s parentview.

Using the ColumnValuesproperty is about 10 percentfaster than getting a handle toa document and using theextended class syntax — forexample, x=doc.fieldname.

Use the ColumnValuesproperty of the Notes-Document class forlookup scripts.

The following example showsimplied casting, where LotusScripthas to convert data types to performthe operation. The implied castingslows this code down by 40 percent.

sub initialize dim a as single dim z as long z=3 a=1.0 z=z+aend sub

Casting, or matching variabletypes in operations, slowsdown script performance.Where possible, avoidcasting by performing opera-tions with like variables. If thisis impossible, use explicitcasting rather than impliedcasting to improveperformance.

Avoid mixing variabletypes (implicit casting)in operations.

This applies when updating between1 and 15 percent of documents in adatabase.

Use Search andFTSearch methodsinstead of the GetViewmethod.

This statement always results in bothconditions being evaluated.

if a=x and b=y

This statement runs 40 percent fasterthan the previous example becausethe second condition evaluates onlyif the first is true.

if a=x then if b=y

Reducing the number ofconditions that need to beevaluated will reduce the timerequired to execute a script.

Simplify If statements.

DetailsWhyWhat to do

Lotus Development Corporation Maximizing Application and Server Performance in Domino 15

Page 20: Maximizing application performance

Continued

Before your script does any updates,use the following statement todisable AutoReload:

source.AutoReload = False

After you disable AutoReload, itremains disabled until your scriptenables it again using this syntax:

source.Reload

The AutoReload option (on bydefault) will update aNotesUIDocument objectevery time a change is madeto the corresponding backend NotesDocument object.

If you are making manychanges to a NotesDocumentobject, turn AutoReload off to eliminate the extraprocessing required to updatethe corresponding NotesUI-Document object.

Disable AutoReloadwhen using UI classes.

The effect of explicit type casting isparticularly noticeable when perform-ing integer operations, where aniteration with a declared integer canperform up to 200 percent fasterthan the same operation with adeclared variant. The difference isless dramatic with string operations.

Because a variant cancontain many different typesof data, the LotusScriptengine needs to interpret thetype of data before operatingon a variant variable. Assign-ing explicit variable typesresults in faster code.

Minimize the use ofVariant types.

DetailsWhyWhat to do

16 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 21: Maximizing application performance

Continued

In the following examples, codefragment A runs about 600 percentfaster than code fragment B.

Fragment ABuff$=Input$(Lof(1),1)Do j=Instr(i,buff$,chr$(13)) If (j<>0) Then Y$(myindex)= _ Mid$(buff$, i, j-i) I=j+1

Else

Y$(myindex)= _Right$(buff$,Len(buff$)-i) End If

Myindex=myindex+1

Loop While (i<len(buff$))And (j<>0)

Fragment B

Do Input #1, y$(myindex) myindex=myindex + 1Loop While eof(1) = FALSE

File operations are faster ifyou read an entire document,then operate on individualrecords, rather than if youread one line at a time.

In Domino R5, the LotusScript string variable limit has been increased to 2gigabytes. The string limitin previous releases is 64kilobytes of memory (32,0002-byte characters).

Read entire files at one time instead ofincrementally.

DetailsWhyWhat to do

Lotus Development Corporation Maximizing Application and Server Performance in Domino 17

Page 22: Maximizing application performance

Continued

For example, the operationx$=x$+"a" is expensive interms of performance.

Avoid copy and appendoperations.

Compute array size beforedeclaration if possible.

Minimize the use ofRedim.

In the following examples, codefragment A runs twice as fast ascode fragment B.

Fragment A

for i=1 to 100 sum = sum + x(i)nextt(1)=sum

Fragment B

for i=1 to 100 t(1)=t(1)+x(i)Next

An alternative to using an array ofstrings would be to create a singlestring of all of the strings in the array,using a delimiter like a carriagereturn. Then use INSTR to search fora particular string.

Storing data in arrays ratherthan in non-array variablescan degrade performance upto 50 percent. If possible,avoid using arrays to storetemporary or intermediatedata.

Note: Domino 5.0 containsnew array functions that maysimplify array operations:ArrayAppend, ArrayGetIndex,ArrayReplace, and Fulltrim.Using these functions inplace of multiple lines ofmanual code that perform thesame purpose will be faster.

Avoid using unneces-sary arrays (i.e. Tempo-rary arrays used forcalculations or datamanipulation)

DetailsWhyWhat to do

18 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 23: Maximizing application performance

Continued

Index the first bound of ann-dimensional array with the inner-most loop, and index the last boundwith the outermost loop. In thefollowing examples, code fragment Aruns 400 percent faster than codefragment B.

Fragment A

for y=0 to 2 for q=0 to 5000

z=z+x(q,y) nextnext

Fragment B

for q=0 to 5000 for y=0 to 2

z=z+x(q,y) nextnext

With n-dimensionalarrays, index the lastbound in the outermostloop.

DetailsWhyWhat to do

Lotus Development Corporation Maximizing Application and Server Performance in Domino 19

Page 24: Maximizing application performance

Continued

Code fragment A is 50 percent fasterthan code fragment B.

Fragment A

If (Asc(x$) = Asc("A"))

Fragment B

If (Left$ (x$, 1) = "A")

Code fragment C is 30 percent fasterthan code fragment D.

Fragment C

If (Asc(Mid$ (x$, 1, 1) =

"A"))

Fragment D

If(Mid$(x, 1, 1)= "A")

In checking for a null string, codefragment E is 30 percent faster thancode fragment F.

Fragment E

If (Len (x$) = 0)

Fragment F

If (x$ = "")

Comparing strings is slowerthan comparing integers.

Compare integersinstead of strings.

DetailsWhyWhat to do

20 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 25: Maximizing application performance

You can use the existing View Selec-tion formulas you have in your viewsas the formula$ parameter for theSearch method.

Depending on the application,using the NotesDatabaseSearch method might be justas effective. Instantianting aview object and opening adocument from a view keepssummary information residentin memory, which is overheadthat can decrease perform-ance.

Use the NotesDatabaseclass Search methodinstead of the NotesView class GetAllDocumentsByKeymethod.

Fragment A is significantly fasterthan Fragment B.

Fragment A

set doc=collection.getfirstdocumentwhile not doc is nothing Set doc= _ collection.getnextdocument(doc)wend

Fragment B

for x = 1 tocollection.count set doc=collection.getnthdocument(x)next x

GetNthDocument is designedto retrieve documents invarying locations in a collec-tion; if you are iteratingthrough a collection one byone, GetNextDocument ismore efficient.

Use the GetNextDocumentmethod instead ofGetNthDocumentmethod when iteratingthrough collections.

DetailsWhyWhat to do

Lotus Development Corporation Maximizing Application and Server Performance in Domino 21

Page 26: Maximizing application performance

Java

An unreferenced object is any objectthat does not have a variable oranother object that refers to it.Unreferenced objects can resultwhen an object variable goes out ofscope or is assigned to anotherobject.

In LotusScript, objects that becomeunreferenced are immediatelydestroyed. While Java as a languagedoes have its own “garbage collec-tion,” this method does not clear thememory used by the underlyingDomino objects.

This function will free memory used byunreferenced Domino objects.The LotusScriptinterface performs this taskautomatically.

Call the recycle functionperiodically

Note that the base class must appearfirst in the list of classes.

Put java classes that areloaded frequentlytowards the top of theclass list (as soon aspossible after the baseclass).

DetailsWhyWhat to do

22 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 27: Maximizing application performance

Tuning Servers for Maximum Performance

The tables below contain suggestions that most often involve configuring your Dominoserver through the directory and NOTES.INI. Each section begins with a question relatedto common configurations or problems. If you answer “yes” or “maybe” to any of thequestions, follow the suggestions in that section to tune your Domino server formaximum performance.

You will find many of the suggestions below revolve around a few major themes:

Z Focus your server on its most important tasks, and disable services that you arenot using

Z Many caches and buffers can be tuned depending on where your problems are

Z The Indexer (Updall) task is one of the most time-consuming tasks. Pay closeattention to factors that affect the Indexer such as NOTES.INI settings, viewsizes, view caches, etc.

Is your server being overloaded?If you need to seriously scale Domino to high user loads, use Domino partitioned serversand clustering to divide the load and take advantage of high end hardware configurations.

Is your server doing unnecessary work?Many server tasks are started by default. If you don’t need a task, don’t start it!Calendaring & Scheduling can require up to 15–20% of a server’s CPU. Some servertasks you may be able to disable are listed below. Note that the AdminP task is necessaryif you are running the Certificate Authority application for SSL or using WebAdministration.

You do not want to automatically track server statistics at regularintervals. Note that you can still generate server statistics ondemand.

Collector

Reporter

You do not run scheduled agents. Agent Manager is not requiredfor WebQueryAgents.

AMgr

You are not using the server for calendaring and scheduling.Calconn

Sched

You are not using the server for electronic mail or workflow.Router

Turn it off IF…Task name

Lotus Development Corporation Maximizing Application and Server Performance in Domino 23

Page 28: Maximizing application performance

Does it take a long time to display views?

Increase the setting for theNSF_BUFFER_POOL_SIZEvariable in the NOTES.INI file. Thissetting increases the maximumsize of the cache for storing views(in bytes). It can be increased toup to ¼ the physical memory forlarge views or many views. Wedon’t recommend increasing itbeyond ¼ the physical memory.

Once you increase it you shouldsee a decrease in I/O activity.Also, watch the statistics:

Database.BufferPool.Maximum

Database.BufferPool.Peak

Database.BufferPool.PercentReadsInBuffer

Note that the BufferPool.Peakvalue can exceed theBufferPool.Maximum value slightlydue to the algorithms used tocalculate the value.

Large views take longer to display.Caching these views in a largerview buffer will speedperformance, instead of forcing theserver to read the view from disk.

Increase the viewbuffer on the server.

DetailsWhyWhat to do

Does it take a long time to access databases?

Continued

Large databases require more I/Oand use more memory, taxingprecious resources.

Decrease the size ofthe database,perhaps by archivingold or little used parts.

Domino flushes the cache every 5 seconds. The defaultsetting of entries is MAX(25, NSF_BUFFER_POOL_SIZE/300KB). Once youincrease it you should see adecrease in I/O activity.

This setting determines themaximum number of databaseopen/close handles in the cache.You can increase this up to 1872entries.

Increase theNOTES.INI settingNSF_DBCACHE_MAXENTRIES.

DetailsWhyWhat to do

24 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 29: Maximizing application performance

Clustering provides a means forload balancing heavily usedservers and/or databases. Keyparameters include Server_Availability_Threshold andServer_MaxUsers.

Domino has superior clusteringtechnology that provides highavailability and failover for heavilyused servers or databases.

Use clusters.

Put another replica of thedatabase on a clustered node.

If you are using a single server,put the highly used database on adifferent hardware array and referto it via a database link.

Split users across multiple replicasto improve performance instead ofburdening one database andserver with all users.

Distribute access of ahighly used databaseacross replicas.

Because large databases requiremore I/O and use more memory;increasing these will improve theperformance.

Upgrade the I/Osubsystem or addmore memory.

DetailsWhyWhat to do

Do you have a uni-processor system?

More replica tasks will notimprove performance with oneprocessor. Keep the default at1.

Do not increase the numberof Replica tasks.

More indexers will not improveperformance with one proces-sor. Keep the default at 1.

Do not increase the numberof Indexer tasks.

Domino automatically deletessessions/tasks that have beenidle for more than 10 seconds.

This setting sets the maximumnumber of Notes clientsessions allowed concurrently.By default, it is unlimited. Youmight want to limit the numberof Notes client sessionsallowed to provide betterservice.

Increase theSERVER_MAXSESSIONSin the NOTES.INI (if runningin a mixed Notes andbrowser client environment).

DetailsWhyWhat to do

ThreadsAn increased number of threads does not always provide increased performance. Blindlyincreasing the number of threads will not increase performance because all of thosethreads could still run into a system resources bottleneck; while there might be morethreads available, there would not be more system resources available, and users will notsee an increase in performance.

Lotus Development Corporation Maximizing Application and Server Performance in Domino 25

Page 30: Maximizing application performance

The effects of increasing the number of threadsAn increase in the number of HTTP threads does not affect CPU utilization, but it doesincrease the use of memory and I/O activity. Lotus tests have shown there can be adegradation in performance and an increase in memory consumption if there are moreHTTP threads defined than are needed. You should therefore set the number of threadscarefully.

How to set the correct number of threadsDetermining the optimum number of HTTP threads takes some server load testing andtuning. First, start by setting the number of HTTP threads (the “HTTP Threads” setting inthe Server document) to 10% of the estimated number of Web users. For example, if youanticipate 200 Web mail users, start by setting the maximum number of threads to 20.

Then, simulate the user load and check the Domino.Active.Threads.Peak statistic bytyping the following in the Domino server console:

show statistic domino.threads.active.peak

Keep in mind that this peak number will not exceed the maximum number of threadsallowed. Determine if your server is reaching the maximum number of threads set bycomparing this statistic to the setting for the maximum number of threads.

Once you have determined the average peak number of threads used, set the maximumnumber of threads in the server document to a value slightly above the peak value. Thiswill be the optimal setting for maximum performance of your Domino server.

Do you have an active, large scale Domino Server?

Continued

A good guideline is to set thenumber of indexers to thenumber of CPUs minus one.For example, if your server has4 processors, use 3 indexers.Be careful not to run too manyindexers, which will preventother server processes fromgetting to the CPUs.

Multiple processors can handlemore than one indexer task.Views will be more likely to beup to date.

Increase the number ofIndexer tasks.

In heavier utilized environ-ments (a guide is 1000-2000active users) set the param-eters to SERVER_MAX_CONCURRENT_TRANS=1000and SERVER_POOL_TASKS=100.

The first parameter sets themaximum number of NRPCtransactions that should beexecuted by the Domino Serversimultaneously. The second,governs the number of IOCP"worker" threads to handle theactive sessions.

Increase the NOTES.INIparameters SERVER_MAX_CONCURRENT_TRANS &SERVER_POOL_TASKS

DetailsWhyWhat to do

26 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 31: Maximizing application performance

A good guideline is to set thenumber of replica tasks to thenumber of CPUs minus one. Forexample, if your server has 4processors, use 3 replica tasks.

Multiple processors can handlemore than one replica task.Replicas will be bettersynchronized.

Increase the number ofReplica tasks.

DetailsWhyWhat to do

Is Your CPU saturated? Is the Indexer a bottleneck?

This setting is undocumentedand unsupported in 4.5x. Thiswill be the default behavior inDomino 5.0.

This setting will not force animmediate rebuild of namespaceviews (such as those used forlooking up addressees in e-mail)if they are out of date. Theindexer will still update views inbackground. This settingprovides faster name resolution.

Set the NOTES.INI settingSERVER_NAMELOOKUP_NOUPDATE equal to 1.

This setting is undocumentedand unsupported.

This setting will disable theautomatic updating of hiddenviews in the Name & AddressBook.

Set the NOTES.INI settingUPDATE_NAB_VIEWS_DISABLE equal to 1.

This setting is undocumentedand unsupported. The default is1 minute. The unit for thissetting is minutes. LIMIToverrides TIME setting if LIMITnumber of update requests arereceived.

Increasing this value will causethe indexer to update hiddenName & Address views lessoften.

Increase the NOTES.INIsettingUPDATE_NAB_SUPPRESSION_ TIME.

This setting determines at whatnumber of view updaterequests the view will beupdated and the indexer will berun. LIMIT overrides TIMEsetting if LIMIT number ofupdate requests are received.

Increasing this value will meanthe indexer will run lessfrequently, freeing up serverresources.

Increase the NOTES.INIsetting UPDATE_SUPPRESSION_LIMIT.

This setting determines theminimum amount of time thatmust pass before the indexerruns again. The default is 1minute. The unit for this settingis minutes.

Increasing this value will meanthe indexer will run lessfrequently, freeing up serverresources.

Increase the NOTES.INIsetting UPDATE_SUPPRESSION_TIME.

See above.See above.See “Increase the number ofIndexer tasks” in the previ-ous section

DetailsWhyWhat to do

Lotus Development Corporation Maximizing Application and Server Performance in Domino 27

Page 32: Maximizing application performance

Hardware recommendationsSoftware performance is directly related to the speed of the hardware it runs on.Hardware speed in Domino is most visible in the following ways:

Processors affect:

Z Indexer speed

Z Replicator speed

Z Number of maximum possible database transactions

Z Number of add-ins that can run in parallel

Disk access affects:

Z Number of maximum possible database connections

Z Speed of database and view opening

Memory affects:

Z Number of maximum possible simultaneous Notes client connections (sessions)

Z Size of caches

Z Server add-in task performance (less paging to disk)

Many of the suggestions below revolve around these themes as well.

Logging can drain performance.Logging to Domino databases ismore resource-intensive thanlogging to text, and logging to bothformats is never necessary.

Log to text files or turnoff logging completely ifpossible.

TCP/IP is a scalable protocol,whereas older protocols likeNetBIOS and SPX are not.

Use TCP/IP.

Upgrade from 10Mbps cards andnetworks to 100Mbps ones.

Check your networkbandwidth.

Move from EISA-based systemsand controllers to PCI-basedsystems.

This hardware will reduce contention on databases.

Use disk controllerswith non-volatile diskcaches.

Use an 8K stripe (on Digitalsystems) or a 16K stripe (on IBM®Netfinity®).

This will speed up databaseaccess times, which can be I/Ointensive.

Use RAID striping/mirroring (e.g., RAID1-0) and/or increase thestripe size.

You can increase drive speedsfrom 5,400 rpm to 7200 rpm. SCSIis better than IDE.

Database accesses can be I/Ointensive.

Use faster disk drives.

For example, consider putting thepage file on one disk, the Dominoexecutable on a second disk, andthe log file on a third.

Like multiple processors, multipledisks can do more work (I/O) inparallel.

Spread databases andprograms acrossphysical disks.

DetailsWhyWhat to do

28 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 33: Maximizing application performance

Appendix A: Frequently Asked Questions

Applications

What’s faster: LotusScript or Java?In terms of performance and functionality, Java and LotusScript are comparable. Thereare some differences between the two languages in terms of architecture that may affectthe performance of your application, depending on its design:

Z If your application will be multi-threaded to handle complex processing, useJava. Java has a thread model built into the language and allows you to spawnthreads. LotusScript does not support multi-threading.

Z LotusScript agents run on the server, while Java agents run on the browser client.

What’s faster: LotusScript or formulas?Formulas that need only a single @function, such as @Command([FilePrint]), are moreefficient and perform better than scripts that do the same thing. Formulas also performbetter than script when you want to update more than 15 percent of the documents in thecurrent database and the logic is simple enough to produce with @functions.

Scripts are often more efficient than complex formulas that use many @functions.LotusScript accesses documents more efficiently and quickly than a formula that uses@functions to “touch” many databases or documents.

The LotusScript user interface (front-end) classes use the same underlying code as theirequivalent @commands, so LotusScript won’t perform better than the formula languagewhen you use these classes. The database (back-end) classes, however, use different codeand perform more quickly than the equivalent @functions.

What are the performance considerations in upgrading older applications?In upgrading applications from versions 3.x to 4.x, there are two main areas where youcan increase performance:

1. Convert 3.x hidden fields to form events

If your application was created in Release 3.x, it may include forms withhidden fields containing formulas that process a document when it’s openedor saved. To improve the performance of the application, convert theformulas to LotusScript, and use the PostOpen and QuerySave form events.

2. Update formulas

Later releases of Domino contain many new and improved @functions.Evaluate whether to incorporate changes to @functions into existingapplications. For example, if a Release 3.x application contains a longformula to add a set of numbers, you can now use @Sum to simplify theformula.

Lotus Development Corporation Maximizing Application and Server Performance in Domino 29

Page 34: Maximizing application performance

Appendix B: Resources for additional information

www.notesbench.orgPublished benchmarks andtest results for Dominoservers by different hardwarevendors. The NotesBenchConsortium is anindependent, non-profitorganization dedicated toproviding Domino and Notes performance information tocustomers.

NotesBench Consortium site

www.lotus.com/bpgBest Practices Guide

www.notes.net/today.nsfAn article that providesdetails on tests of CPUscaleability.

Optimizing Your ServerPerformance: Part 2

By James Grigsby, NirmalaVenkatraman, and SusanFlorio

www.notes.net/today.nsfAn article that providesdetails on server performanceanalysis, including bench-marking tools. This articlealso details examples ofserver performance testsperformed at Iris on portencryption andNSF_BUFFER_POOL_SIZE.

Optimizing Your ServerPerformance: Part 1

By James Grigsby, CarolZimmet, and Susan Florio

The Notes AdministrationHelp database(HELPADMN.NSF)

Platform specific suggestionson performance tuning.

Optimizing serverperformance

www.lotus.com/performanceA central web page listingperformance informationresources.

Lotus Performance Zone

LocationDescriptionResource

30 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 35: Maximizing application performance

Appendix C

This article resides in “Iris Today,” the technical Webzine located on the http://www.notes.netWeb site produced by Iris Associates, the developers of Domino and Notes. Please visit Notes.netto obtain the latest version of this article as well as other related articles.

Expanded Command Caching introduced in Domino 4.61by Andrew Wharton

Since its initial release, the Domino HTTP server has had the ability to keep a volatile,in-memory cache of requested HTML pages called the Command Cache. The very natureof a dynamic Web applications server would preclude the caching of all Web pages.Some Web pages, however, are “static enough” that they can be reused when the sameURL or command is issued from a browser. This section describes how the CommandCache works so that you can design applications that take advantage of its capabilities —and the performance gains it provides.

Command Cache fundamentals The Command Cache saves Web pages in memory in the event that the same Web pageURL will be requested in the future, and that the cached page will still be valid to servefor that URL. To do this correctly, the cache must understand the nature of the pagebeing saved, and it must know how to determine if that page is still valid for serving.While the Command Cache has been part of Domino since its inception, the role of theCommand Cache is continually expanding as we make it more and more capable ofunderstanding pages and determining their validity.

Caching URL commands The following types of Domino URL commands (and the HTML that they generate) arecurrently the only candidates for the Command Cache:

?OpenDatabase

?OpenView

?OpenDocument

?OpenForm

?ReadForm

Lotus Development Corporation Maximizing Application and Server Performance in Domino 31

Page 36: Maximizing application performance

Other commands (for example, ?EditDocument) are not considered for caching. Dominoonly serves pages from the Command Cache if the URL request exactly matches theURL of the cached pages, even though Domino URL syntax allows multiple ways tospecify the same URL command (by using replica IDs instead of database names, orview names instead of view UNIDs).

Caching @functions Determining the algorithm to make an accurate and timely decision as to which Web pages are cacheable is one stumbling block to making a very useful caching system. In 4.6, we considered the very presence of @functions (among others) too volatile, and thus, did not consider any pages with @functions as candidates for caching.Unfortunately, this meant that many Web pages could not take advantage of caching and the performance gains that it provides.

In 4.61, much has changed. As part of the ongoing effort to provide performanceimprovements in the Domino server, we now provide the ability to cache Web pages thatcontain @functions. This is a very simple statement with very powerful implications forthe Web site administrator, the Web application designer and the Web application user.

Domino 4.61 now has the ability to analyze all macro language (@function) formulas fortheir dependencies through the Formula Analyzer. Rather than exclude all pages thatcontain any @function formulas from the Command Cache, the Formula Analyzerintelligently examines the formula on the page and decides its level of volatility. Bydoing this first, Domino can decide immediately whether the command is too volatile tobe cached (for example, the Web page contains @Now) and, perhaps more importantly,under what conditions a cached command becomes invalid.

The logic for these caching schemes is based on very conservative thinking. In all caseswhere the slightest bit of ambiguity exists, Domino will not cache the page. Weconsidered the performance loss of re-rendering the resultant HTML to be a smalltradeoff to the possibility of sending out-of-date, incorrect, or inappropriate informationto the requesting user.

The Formula Analyzer is turned OFF by default in 4.61, meaning that any @functionwill result in the page not being cached. To enable the Formula Analyzer, place thefollowing line in your NOTES.INI file:

DominoAnalyzeFormulas=1

It is important to note that without this setting, the Command Cache behaves exactly theway that it did in 4.6; you will still get the benefit of command caching, just without theexpanded usefulness of caching Web pages where @formulas were used in the process.

32 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 37: Maximizing application performance

Cache flags When the Formula Analyzer examines a command invoking @formulas, flags areassigned to that cache candidate based on the evaluation of the @formula(s), amongother things. The following flags are used by the Domino HTTP server to determine thecache strategy, explained in the next section. (A cache candidate can and often does havemultiple flags.)

OffDb — The page uses data outside the current database. This includes the use of CGIvariables.

TimeVariant — The page uses time-variant data (such as @Now).

HadEffect — The page has an important side-effect (such as @DialogBox).

UsedEnv — The page uses the environment (NOTES.INI). This does not include CGIvariables.

UserVariant — The page is dependent on the user’s identity. This includes using anydata or design note that includes Read ACLs, Readers fields, Authors fields or controlledaccess sections.

DesignUserVariant — The page is from a database that has protected design elements.

DbData — The page uses data in the database other than the referenced document. Thisincludes all views, embedded views in forms, and so on.

UsedDocId — The page uses the document’s ID.

UsedNewDoc — The page uses a newly-created in-memory note.

Unknown — The page does something that couldn’t be analyzed (such as executedLotusScript).

Error — The page generated an error of some sort.

Cache strategyDomino uses the cache flags to determine the cache strategy for a given command. Acached command can have multiple cache strategies. The most restrictive strategy wins.The strategy is stored with the command if it is cached, and is used to help determinewhether the command is still valid each time it is retrieved from the cache. The cachestrategies are:

DontCache — Don’t cache the response at all.

Document — Invalidate the cached response when the document changes.

DbDesign — Invalidate the cached response when the database design changes.

DbData — Invalidate the cached response when any of the data in the database changes.

OnlyAnonymous — Cache the response, but only serve it when the user is anonymous.

Lotus Development Corporation Maximizing Application and Server Performance in Domino 33

Page 38: Maximizing application performance

Any commands with the following flags are not cached (the DontCache strategy):

OffDbTimeVariantHadEffectUsedEnvErrorUnknownUserVariant (if authenticated)DesignUserVariant (if authenticated)

Here is an example of how command flags set the cache strategy. We will annotate thecache flags Flag(flag) where flag refers to the flags above. The cache strategy will beannotated as Strategy(strategy) where strategy refers to the strategies above. Using thisnotation, cached commands are assigned a cache strategy that defines how the cache isinvalidated. This is illustrated by the following pseudocode:

Sub CACHESTRATEGYCASE OPENDOCUMENTCACHESTRATEGY = DocumentIf Flag(OffDb) or Flag(TimeVariant) or Flag(HadEffect) or Flag(UsedEnv) thenCACHESTRATEGY = DontCache //don’t cachereturn CACHESTRATEGY //we’re doneEnd IfIf Flag(UsedDocId) and Flag(UsedNewDoc) thenCACHESTRATEGY = DontCache //don’t cachereturn CACHESTRATEGY //we’re doneEnd IfIf Flag(UserVariant) or Flag(DesignUserVariant) thenIf USER_AUTHENTICATED thenCACHESTRATEGY = DontCache //don’t cachereturn CACHESTRATEGY //we’re doneEnd If //not authenticatedCACHESTRATEGY = CACHESTRATEGY + OnlyAnonymous //continueEnd IfCACHESTRATEGY = CACHESTRATEGY + DbDesign //continueIf Flag(DbData) then//remove Document strategy and add DbData strategyCACHESTRATEGY = CACHESTRATEGY - Document + DbData //continueEnd Ifreturn CACHESTRATEGYCASE OPENFORM// etc.End Sub

34 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 39: Maximizing application performance

You are smarter than your serverThe Command Cache does a good job understanding the page creation process andautomatically invalidating pages, but it is not perfect. Because of its conservative nature,it errs on the side of not caching pages in order to guarantee the correctness of the pagereturned. You may decide that certain pages can be cached where the server determinesthat they cannot be. We’ve provided controls so that you can override the cache behaviorwhere appropriate. The following fields can control the use of the cache to some extent:

$CacheOptions — If the value of this field is the text string “0”, then the response is notcached.

$CacheValid — The value of the numeric text string N will be evaluated and willprotect the response from validity checks for N seconds. This setting can be globally setby using the NOTES.INI setting “DominoDefaultCacheValid=N.” The default for theHTTP server is N=0.

The $CacheValid field lets you tell the cache that this page should be considered validfor a certain number of seconds regardless of what Domino determines the cache strategyto be. Consider a simple home page that is being continually edited. As this page wouldbe given the “Document” strategy, the cache entry would become invalid each time thepage is edited. You consider it acceptable that the home page is not continually updated as a tradeoff for performance. You can communicate this to Domino by creating a$CacheValid field on the document with a value of “180.” This means that the results ofthe page should be considered valid for 180 seconds. After that time, the normal validitychecks will take place.

Viewing the cache strategy and flags for a pageIf the NOTES.INI variable “DominoTraceCmdCache=1” is set, the cache strategy andthe cache flags will be included in the HTTP header information that is sent to thebrowser when a page is served. To view this information, you can use a tool that displaysthis information (such as a wire-sniffer) or download the following Java application(9Kb) written by Bob Congdon at Iris. This tool is not a supported product; it’s justintended to be a useful utility.

Make sure that CLASSPATH has “.” on it, and run the application by entering “javaSpyFrame” at the command line. While Bob developed the application using the JDK1.1.1, it should run fine with JDK1.0x since it doesn’t use any JDK 1.1.1-specificclasses.

The following header information is sent:

X-DominoCmdCache-EvalInfo — Following this is a comma-separated list of flagwords (information pieces) that the Formula Analyzer set in the process of evaluating thepage (see above).

X-Domino-CmdCache-Strategy — Following this is a comma-separated list of flagwords that denotes the cache strategy that was assigned to the command based on theinspection of the EvalInfo (see above).

Lotus Development Corporation Maximizing Application and Server Performance in Domino 35

Page 40: Maximizing application performance

X-Domino-CmdCache-ValidSeconds — This is the number of seconds that theresponse will be assumed to be valid without the benefit of a validity check. This is thetime set in either the $CacheValid field of the DominoDefaultCacheValid NOTES.INIvariable.

X-Domino-CmdCache-CheckValid — This is the clock time that states when thevalidity check will again be allowed.

X-Domino-CmdCache-DataMod — This is the recorded data modification date that isused for the validity checking.

X-Domino-CmdCache-DesignMod — This is the recorded design modification dateused for validity checking.

Cache statisticsYou can check the efficacy of your Command Cache by monitoring the following serverstatistics:

Domino.Cache.Command.Count — This is the actual number of commands that arecontained in the Command Cache.

Domino.Cache.Command.MaxSize — This is the maximum number of commands thatcan be cached. This is the number configured from the Server document in the PublicAddress Book using the “Maximum Cached Commands” field.

Domino.Cache.Command.HitRate — This is the percentage-ratio of the number oftimes a valid cache entry is found in the cache to the number of times the cache wasinvestigated for a cache entry.

Domino.Cache.Command.DisplaceRate — This is the percentage-ratio of the numberof times that a new cached command displaces an aged command to the number of timesthe cache was investigated for a cache entry.

36 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 41: Maximizing application performance

List of @FunctionsThe following is a list of @functions and the Eval flags that are set at compute time. If afunction is not listed here, safely assume that there is no associated Eval flag set. TheEval flag Depends means that the evaluation of the entire formula will determine theEval flag set. If the @function says “Fallback,” that means that there is an evaluation thatis Web server-specific and this is the non-Web version. Its converse is “Web.”

@Accessed — OffDatabase,UsedDocId

@Certificate — OffDatabase

@Command - Web — Depends

@Command([Compose]) — Depends,DbDesign,OffDatabase

@Command([FileSave]) — HadEffect

@Created — UsedDocId

@DbColumn - Fallback — UserVariant,DbDesign,DbData,Unknown,Depends,OffDatabase

@DbCommand - Fallback — Unknown

@DbCommand - Web — Depends

@DbLookup - Fallback — Depends,Unknown,DbData,DbDesign,UserVariant,OffDatabase

@DbManager — DbDesign

@DbTitle — DbDesign

@DocumentUniqueID — UsedDocId

@Environment — HadEffect,UsedEnvironment

@GetDocField — DbData,UserVariant

@GetPortsList — UsedEnvironment

@GetProfileField — DbData,UserVariant

@InheritedDocumentUniqueID — UsedDocId

@MailEncryptSavedPreference - Fallback — UsedEnvironment

@MailEncryptSentPreference - Fallback — UsedEnvironment

@MailSavePreference - Fallback — UsedEnvironment

@MailSend - Fallback — HadEffect

@MailSignPreference - Fallback — UsedEnvironment

Lotus Development Corporation Maximizing Application and Server Performance in Domino 37

Page 42: Maximizing application performance

@Modified — UsedDocId

@NoteID — UsedDocId

@Now — TimeVariant

@PostedCommand - Web — Depends

@Random — OffDatabase

@Responses — DbData

@SetDocField — HadEffect,UserVariant

@SetProfileField — HadEffect,UserVariant

@TextToTime — TimeVariant

@Today — TimeVariant

@Tomorrow — TimeVariant

@Unique — None,Depends,OffDatabase

@URLGetHeader - Fallback — OffDatabase

@URLOpen - Fallback — OffDatabase,HadEffect

@UserAccess - Web — OffDatabase,UserVariant,DbDesign

@UserName — UserVariant

@UserPrivileges — DbDesign,UserVariant

@UserRoles - Fallback — DbDesign,UserVariant

@UserRoles - Web — DbDesign,UserVariant

@V3UserName — UserVariant

@ViewTitle — DbDesign

@Yesterday — TimeVariant

@Zone — TimeVariant

38 Maximizing Application and Server Performance in Domino Lotus Development Corporation

Page 43: Maximizing application performance

Recommended