Performance tips, Cache component definitions – Apple WebObjects 3.5 User Manual

Page 156

Advertising
background image

Chapter 9

Deployment and Performance Issues

156

users to be able to end their sessions first, you might write the following
code:

// WebScript Application.wos
id startDate;
- init {

[super init];
[self setMinimumActiveSessionCount:1];
return self;

}

- sleep {

if (!startDate) // get the start date from statisticsStore
{

[[[self statisticsStore] statistics]

objectForKey:@"StartedAt"];

}
// Compare start date to current date. If the difference is
// greater than 24 hours, refuse any new sessions.
if (([[NSDate date] timeIntervalSinceReferenceDate] -

[startDate timeIntervalSinceReferenceDate]) > 86400)

{

[self refuseNewSessions:YES];

}

}

When the application’s active session count falls below the minimum of
one session, it will terminate. Sending

refuseNewSessions:

guarantees that the

active session count will eventually fall below the minimum.

Performance Tips

As more users access your application, you may become more concerned about
its performance. Here are some suggestions about how to improve an
application’s performance.

Note:

This section covers only programmatic ways to improve performance.

Performance is affected by several factors, such as the load on your system, the
amount of memory available, and whether the load is shared among multiple
application instances. For information about other ways to improve
performance, see the online document Serving WebObjects. In particular, you may
want to check out the section “Testing Performance,” which describes some
tools you can use to do performance testing.

Cache Component Definitions

As described in the chapter “WebObjects Viewed Through Its Classes”
(page 63), each component has a component definition consisting of the

Advertising