Skip Headers
Oracle® Application Server Performance Guide
10g Release 3 (10.1.3.1.0)

Part Number B28942-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

4 Additional Performance Areas

This chapter covers performance information for the following Oracle Application Server areas:

4.1 Improving TopLink Performance

Oracle TopLink (TopLink) provides features to optimize application performance, including the following important areas:

The TopLink documentation includes information on these important TopLink performance areas. See the appropriate chapters in the documentation for more information about tuning your application to optimize TopLink performance.


See Also:


4.2 Improving JTA Performance

This section describes JTA performance options, including the following topics:

4.2.1 Configuring Two-Phase Commit Logging for Performance

Using configuration options you can control the type and level of two-phase commit logging. To change the configuration options, you can modify the transaction-manager.xml file or use the JTA Resource MBean available from the Transaction Manager page in Application Server Control Console. When you configure two-phase commit logging, you need to be aware of the transactional ramifications of turning two-phase commit logging off.


Note:

Two-phase commit logging is off by default. When you use the default logging level, JTA resources do not support recovery and full ACID properties.

Table 4-1 shows the two-phase commit logging configuration options that you can set in transaction-manager.xml or using the JTA Resource MBean.

Table 4-1 Two-phase Commit Logging Log Type Configuration Options

Log Type Description Performance Notes

none

Specifies no logging (or recovery).

This is the default value.

When recovery and ACID properties are not required, use this option for best performance.

file

File logging specifies logging to the file system for transaction recovery.

File logging typically performs better than database logging, due to lower overhead.

database

Database logging specifies logging to an Oracle database for transaction recovery.

File logging typically performs better than database logging.



See Also:

See the Oracle Containers for J2EE Services Guide for more information on setting two-phase commit logging configuration options, and for the details on the transactional and recovery ramifications of specifying different log type configuration options.

4.2.1.1 Setting JTA Store File Logging Options

Table 4-2 describes the performance settings for file store logging that you can set in transaction-manager.xml or using the JTA Resource MBean. The default settings are adequate if the maximum concurrent number of two-phase commit transactions is less than 256.

To determine the maximum concurrent number of two-phase commit transactions, you can use the TwoPhaseCommitCompletion.maxActive metric from the JTAResource metric table.


See Also:

Table D-1 for details on JTA resource metrics

Table 4-2 JTA File Store Logging Parameters

Parameter Description Performance Notes

maxOpenFiles

Specifies the maximum number of file descriptors that can remain open or active; when this number is exceeded the oldest file descriptors are released until the xid is requested again.

Avoid exceeding the maxOpenFiles if possible.

Default Value: 256

The optimal value is large enough to cover the maximum number of concurrent requests that use two-phase commit transactions (plus a small additional number of files that may be required for recovery).

The maxOpenFiles value is limited by the Operating System open file descriptor limit.

minPoolSize

Specifies the number of files that are pre-allocated to the pool during startup.

Default Value: 40

The optimal value is large enough to handle the maximum number of concurrent two-phase commit requests.

Note: if the maximum concurrency is large, then to avoid a high cost at startup, you can increase this value from the default, but set the value to something smaller than maxOpenFiles value.

oldFileReleaseSize

Specifies the number of the oldest file handles which are closed when maxOpenFiles is exceeded.

Default Value: 20

If you expect that you will repeatedly exceed the maxOpenFiles value, which is not recommended, then increasing this value to release more file handles may help reduce the number of times that maxOpenFiles is exceeded.



Note:

The number specified for maxOpenFiles does not limit the number of transactions; if maxOpenFiles is exceeded, old file handles are released, but new transactions can still be created (see the oldFileReleaseSize parameter).

4.2.2 Configuring JTA Data Sources for Performance

This section covers the following areas:

4.2.2.1 Specify the Data Source Type

Non-XA compliant data sources are generally faster than XA data sources. When a full XA-compliant two-phase commit is required, you must use an XA data source.

If transaction logging is set to none, any number of XA or non-XA compliant resources can be enlisted in a global transaction; however, in this case there are no ACID guarantees nor recovery.

If transaction logging is enabled, participants in a global transaction must be XA-compliant. The last resource commit feature allows for a single non-XA-compliant resource to participate in an XA transaction.

4.2.2.2 Use Last Resource Commit

In addition to allowing a single non-XA resource to participate in a global transaction, last resource commit can also be used as a performance optimization. By enlisting an XA-capable resource as a non-XA resource and using last resource commit, a gain in performance is achieved because the resource does not need to perform XA logging. Also, the resource would never be put in doubt, that is prepared, which would prevent resources from being locked. Although last resource commit can be used as a performance optimization, it is at the cost of guaranteed correctness.

4.2.2.3 Use a Single Data Source Where Possible

When your application uses multiple data sources to access a single resource, this can lead to unintended use of two-phase commit operations (using XA-transactions). In some cases you can improve performance by changing the configuration; this configuration change allows OC4J to eliminate two-phase commits and replace them with one-phase commits.

You can use the following metrics to check the number of one-phase commits, two-phase commits, and the count of global transactions that do not enlist any resources:

/oc4j/JTA/SinglePhaseCommitCompletion.completed
/oc4j/JTA/TwoPhaseCommitCompletion.completed
/oc4j/JTA/AverageCommitTime.completed


Note:

The /oc4j/JTA/AverageCommitTime.completed metric shows all JTA involved transactions but does not show local transactions.

Whenever there are multiple data sources used within the same global transaction, use of XA two-phase commit transactions occurs, even if the data sources actually point to the same database. If you have deployed the data sources for your application in a single database and schema, you may be able to reconfigure your application to use a single data source. This would improve performance by changing two-phase commits to single-phase commits.

Thus, transactional applications that use both traditional database resources, such as tables, and also use OJMS, where resources reside on the same database, can avoid some two-phase commits by specifying a single data source for each resource. This change should improve performance and requires that the OJMS data source configuration matches that specified for accessing the tables.


See Also:

Oracle Containers for J2EE Services Guide for more information on Local and Global Transactions

4.2.3 Monitoring JTA Resources

When you monitor JTA resources, be aware that errors can cause performance problems. You can determine if there are JTA errors by looking for Rollback or Exception counts greater than 0 using the metrics in the JTAResource metric table. For example, look at the values of the following metrics: RollbackExceptionCount, RolledbackCount, or SystemExceptionCount.

Note that certain performance problems may also affect JTA errors. For example if performance is bad, timeout errors may occur. In this case, look at the value of the metric RolledbackDueToTimedOutCount.

4.3 Improving EJB Performance

This section includes the following topics:

4.3.1 Improving MDB Performance

This section covers some of the important performance related EJB configuration properties specified in the orion-ejb-jar.xml configuration file that apply for Message Driven Beans (MDBs), including the following:


See Also:

Oracle Containers for J2EE Services Guide and the chapter, Chapter, "Oracle Enterprise Messaging Service (OEMS)" for more information on using and configuring MDBs

4.3.1.1 Setting the JMS Connector Receiver Threads

When you set the number JMS Connector receiver threads for an MDB, this can improve performance either when there are many concurrent users sending messages to the queue of an MDB, or when significant processing occurs in the onMessage method. For example, if the onMessage method contains code to call another EJB and the EJB processing can occur concurrently while processing other messages, then setting the JMS Connector receiver threads to a value greater than one can improve performance. Depending on the underlying JMS Connector and the specific MDB, some applications may see significant performance improvements when you increase the value of the JMS Connector ReceiverThreads configuration property.

For example, if a queue contains 100 messages, and the ReceiverThreads is set to the default value, 1, then only one MDB receiver thread processes the messages, in a serial fashion. When you set the ReceiverThreads to 5, this specifies that there can be a maximum of 5 MDB instances that take messages from the queue and process the messages in parallel. In this example, the total time required to complete the processing for the 100 messages may decrease, since in this case OC4J uses up to 5 MDB threads to dequeue and process the messages.


Note:

The JMS Connector ReceiverThreads value specifies a maximum value for threads; not all the threads are necessarily used, depending on the load.

When you specify a JMS Connector ReceiverThreads value greater than 1, this enables multiple instances of the MDB to concurrently process messages from queues. However, in this case any performance improvement depends on the application and on the number of threads you specify. If you specify a value that is too large, this can cause performance to degrade due to resource contention.


Note:

For JMS topics, always set the JMS Connector ReceiverThreads configuration property to the value 1 (only for queues are values over 1 meaningful).

4.3.1.1.1 Consider Message Processing Order Requirements for MDBs

Use JMS Connector ReceiverThreads set to the value 1 if the messages must be processed in order. If you use ReceiverThreads with a value greater than 1, messages are still removed from a queue serially, but the order of processing the messages cannot be guaranteed since the MDB is processing the messages with multiple threads.

4.3.1.1.2 Coordinate Thread Pool and Bean Instance Settings

OC4J allocates the threads used as JMS Connector receiver threads from the work manager thread pool (shown as the jca thread pool using Application Server Control Console and in server.xml) You can limit the number of JMS Connector receiver threads in the work manager thread pool using the max parameter for the jca thread pool. You can also use the min value to set the initial number of available work manager thread pool threads.


Performance Note:

Oracle recommends leaving the jca work manager thread pool at the default setting. Thus, if you want to control concurrency for EJB MDBs, use the JMS Connector ReceiverThreads value.

You need to coordinate the following configuration options when you set the value for the JMS Connector ReceiverThreads:

  • Overall Concurrency Limit: On the system this includes all the thread-pool max threads plus either:

    1. The sum of all the MDB JMS Connector ReceiverThreads configured for your applications deployed to OC4J (if the max for the work manager thread pool, shown as the jca thread pool, is specified at the default value, plus the sum of all threads used by other JCA adapters).

    2. The maximum allowed number of work manager thread pool threads, shown as jca, specified with the max parameter (if this is smaller than the maximum number specified for the sum of all of the JMS Connector ReceiverThreads).

  • Set Minimum MDB Instances Appropriate for the Receiver Threads: There is a one-to-one correspondence between the JMS Connector ReceiverTheads created and the number of active MDB bean instances. When the initial processing time for an MDB may be significant, you should set the min-instances MDB setting to match the number of desired JMS Connector ReceiverTheads, so that these instances are initialized at startup.

    Also, you should configure the MDB configuration min-instances value to be at most as large as the JMS Connector ReceiverThreads setting per MDB.

    To maintain the desired number of instances, set the pool-cache-timout to a value that is large enough so that the MDB instances are not removed when idle.

4.3.1.1.3 Consider the Database Connections When Setting JMS Connector Receiver Threads

The number of JMS Connector ReceiverThreads also multiplies of the number of required database connections, if any, for the MDB. For example, if a particular MDB uses 5 database connections concurrently, and there are 5 active MDB instances, then the number of requested concurrent database connections would be 25. Thus, the number of JMS Connector ReceiverThreads must be included in the calculation of the data source max-connections count.

4.3.1.2 Using the ejbCreate Method for One Time Initialization

An MDB is stateless and contains no specific client state across invocations. However, for nonclient related state, an MDB instance can contain some state across client message handling. For example, state can be maintained for a lookup. In addition, other state information that you may want to cache across onMessage invocations, such as a reference to an EJB, can be initialized in the ejbCreate method and cached to optimize MDB performance.

Remember to destroy the state in the ejbRemove method in case idle MDB objects are removed from the pool and reallocated when needed.

4.3.1.3 Monitoring MDB Resources

When MDBs use OracleAS JMS as a message provider, DMS message related metrics are available from the Oracle Application Server performance monitoring tools.For example, the OracleAS JMS JMSStoreStats metric table includes information for a destination corresponding to a queue that an MDB uses:

destination.value:        name
messageDequeued.count:    x ops
messageEnqueued.count:    x ops
messageCount.value:  n

These metrics show the destination name, the total messages enqueued, the total number of messages dequeued, and the total number currently in the queue.

You can also check the MDB onMessage metrics to check that the time in onMessage is as expected and use the maxActive metric to see the total number of concurrent receiver threads is as expected.

client.active:   1   threads
client.avg:   112   msecs
client.completed:   4   ops
client.maxActive:        1       threadsclient.maxTime:  70       msecsclient.minTime:  130      msecsclient.time:     121      msecs

Note:

When monitoring a JMS destination, other applications besides the MDB may access the destination. Thus, when you test the performance of an application, make sure that you know whether the application is responsible for the message activity that is reported in the metrics.

Application Server Control Console provides information for the performance of all MDBs and of individual MDBs.

To access the summary MDB information, do the following:

  1. From the OC4J home page, select the Administration secondary tab.

  2. In the table, under Services, select the JMS Providers task.

  3. In the in the Performance area, Application Server Control Console displays the following summary information:

    Active Connections
    Messages Waiting for Read
    Messages Waiting for Commit
    Messages Enqueued per Second
    Messages Dequeued per Second
    Messages Paged In per Second
    Messages Paged Out per Second
    Messages Committed Since Startup
    Messages Rolled Back Since Startup
    Messages Expired Since Startup
    
    

To access the individual MDB information, use the Application Server Control Console performance area:

  1. From the OC4J home page, select the Applications secondary tab.

  2. Select the application that you want to monitor.

  3. In the Modules table, select the appropriate EJB module.

  4. In the Message Driven Beans area, select the MDB you want to monitor to see the following information:

    Messages Dequeued   
    Messages Rolled Back   
    Average Message Processing Time (seconds)  
    Number of Available Instances  
    Number of Used Instances  
    
    

See Also:

"OC4J JMS Metrics"

4.3.2 Improving EJB CMP 2.1 Performance

This section covers some of the available performance options for entity beans using CMP, and includes the following topics:


Note:

This section describes several EJBs options that you can use to improve performance of your applications. This section does not describe how to set these options. For details on configuring your EJBs to use various options, refer to the Oracle Containers for J2EE Enterprise JavaBeans Developer's Guide and the Oracle TopLink Developer's Guide.


See Also:


4.3.2.1 Using Efficient SQL Statements and Querying

This section covers using efficient SQL statements and SQL querying. Table 4-3 and Table 4-4 show tuning parameters and performance recommendations related to SQL statements and querying.

Table 4-3 CMP EJBs Using Efficient SQL Statements and Querying

Tuning Parameter Description Performance Notes

Parameterized SQL Binding

Using parameterized SQL and prepared statement caching, you can improve performance by reducing the number of times the database SQL engine parses and prepares SQL for a frequently called query. TopLink and OC4J/CMP does not enable parameterized SQL and prepared statement caching by default, because not all databases and JDBC drivers support these options. Note that the Oracle JDBC driver bundled with OC4J does support these options

Default Value: off

See Also: Oracle TopLink Developer's Guide section, "Configuring Named Query Parameterized SQL and Statement Caching at the Project Level"

Turn SQL parameter binding on for all queries (at the project level). Oracle recommends that you enable parameterized SQL and prepared statement caching for selected databases and JDBC drivers that support these options.

JDBC Statement Caching

Statement caching is used to lower the overhead of repeated cursor creation and repeated statement parsing and creation; this can improve performance for applications using a database.

Note: Use the data source statement caching (and do not use TopLink Statement Caching for CMP).

Default Value: off

See Also: Oracle Containers for J2EE Services Guide section, "Statement Caching with Managed Data Sources"

You should always enable statement caching if your JDBC driver supports this option. The Oracle JDBC driver supports this option. Set this option in data-sources.xml by setting num-cached-statements.

Fetch Size

The JDBC fetch size gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. For large queries that return a large number of objects you can configure the row fetch size used in the query to improve performance by reducing the number database hits required to satisfy the selection criteria.

Most JDBC drivers use a default fetch size of 10. If you are reading 1000 objects, increasing the fetch size to 256 can significantly reduce the time required to fetch the query's results.

Note: The default value means use the JDBC driver default value, which is typically 10 rows for the Oracle JDBC driver.

Default Value: 0

See Also: Oracle TopLink Developer's Guide

The optimal fetch size is not always obvious. Usually, a fetch size of one half or one quarter of the total expected result size is optimal. Note that if you are unsure of the result set size, incorrectly setting a fetch size too large or too small can decrease performance.

Batch Writing

Batch writing can improve database performance by sending groups of INSERT, UPDATE, and DELETE statements to the database in a single transaction, rather than individually.

Default Value: off

See Also: Oracle TopLink Developer's Guide section, "Data Access Optimization"

Enable for all EJBs.


4.3.2.1.1 Querying Container Managed Relationships Performance Tuning

Table 4-4 shows the CMR parameters for performance tuning.

Table 4-4 CMP EJBs and CMR Query Performance Options

Tuning Parameter Description Performance Notes

Batch Reading

Batch reading propagates query selection criteria through an object's relationship attribute mappings. You can also nest batch read operations down through complex object graphs. This significantly reduces the number of required SQL select statements and improves database access efficiency.

Default Value: off

See Also: Oracle TopLink Developer's Guide section,"Using Batch Reading"

Use for queries of tables with columns mappings to table data you also need to retrieve.

You should only use either batch-reading or joining if you know that you are going to access all of the data; if you do not intend to access the relationships, then just let indirection defer their loading.

Batch reading is more efficient for 1-m and other relationships as it reads less data from the database, that is, n versus n*m. Batch reading is also more efficient on logical m-1 relationships as less data may be read. Batch reading also performs better with caching, because if the original object and its relationship were already cached then the batch query does not need to execute (where joining would have already read in all of the data). TopLink supports batch reading for most mappings (1-1, 1-m, m-m, dc, ac) at the query and mapping level.

Join

Join reading is a query optimization feature that allows a single query for a class to return the data to build the instances of that class and its related objects. Use this feature to improve query performance by reducing database access. By default, relationships are not join-read: each relationship is fetched separately when accessed if you are using indirection, or as a separate database query if you are not using indirection.

Default Value: not used

See Also: Oracle TopLink Developer's Guide section, "Using Join Reading"

Use for queries of tables with columns mappings to table data you also need to retrieve.

You should only use either batch-reading or joining if you know that you are going to access all of the data; if you do not intend to access the relationships, then just let indirection defer their loading.

TopLink supports joining for only 1-1 and 1-m at the query level, but only 1-1 (inner) at the mapping level. For performance, Join is recommended only for joining logical 1-1 relationships.

Joining is not supported to related classes that use inheritance and have subclasses that span multiple tables.

Indirection

Without indirection on, when TopLink retrieves a persistent object, it retrieves all of the dependent objects to which it refers. When you configure indirection (also known as lazy reading, lazy loading, and just-in-time reading) for an attribute mapped with a relationship mapping, TopLink uses an indirection object as a place holder for the referenced object: TopLink defers reading the dependent object until you access that specific attribute. This can result in a significant performance improvement, especially if the application is interested only in the contents of the retrieved object, rather than the objects to which it is related.

Default Value: Value Holder Indirection On for all CMRs

See Also: Oracle TopLink Developer's Guide section,"Indirection"

Leave the indirection option at the default value. That is, use indirection for CMP for all situations. Querying the referenced object using Join or Batch Reading is more efficient.


4.3.2.2 Cache Configuration Performance Tuning

Table 4-5 shows the cache configuration options.

Table 4-5 CMP EJBs and Cache Configuration Options

Tuning Parameter Description Performance Notes

Object Cache

TopLink sessions provide an object cache. CMP 2.1 applications which use the TopLink persistence manager create TopLink sessions which by default use this cache. This cache, known as the session cache, retains information about objects that are read from or written to the database, and is a key element for improving the performance of a TopLink application. Typically, a server session's object cache is shared by all client sessions acquired from it. Isolated sessions provide their own session cache isolated from the shared object cache.

Default Value: enabled

See Also: Oracle TopLink Developer's Guide section, "Object Cache"

Disable (use isolated cache) for pessimistic queries.

Query Result Set Cache

In addition to the object cache in TopLink, TopLink also supports a query cache:

  • The object cache indexes objects by their primary key, allowing primary key queries to obtain cache hits. By using the object cache, queries that access the data source can avoid the cost of building the objects and their relationships if the object is already present

  • The query cache is distinct from the object cache. The query cache is indexed by the query and the query parameters – not the object's primary key. This allows for any query executed with the same parameters to obtain a query cache hit and return the same result set

Default Value: not used

See Also: Oracle TopLink Developer's Guide, section, "Caching Query Results in the Session Cache"

Use for frequently executed non-primary key queries with infrequently changing result sets.

Use with a cache validation timeout to refresh as needed.

Cache Size

Default Value: SoftCacheWeakIdentityMap size 100 (per EJB).

See Also: Oracle TopLink Developer's Guide section, "Guidelines for Configuring the Cache and Identity Maps"

Set the cache size to be as large as the maximum number of objects (of the same type) referenced within a transaction

Locking

Oracle supports the locking policies shown in Table 4-6.

Default Value: no locking

See Also: Oracle TopLink Developer's Guide sections, "Configuring Locking Policy" and "Understanding Descriptors and Locking"

.

Cache Usage

Using Cache Usage conform does not check the session cache. For read-all it first checks the database, then conforms the result with the unit of work changes and new and deleted objects. For read-object is first checks the unit of work changes and new objects for a matching object, then checks the database and then conforms the results with changes and deleted objects.

Conforming is more similar to the POJO default option CheckCacheByPrimaryKey than CheckCacheThenDatabase, although somewhat similar to CheckCacheThenDatabase for read-object queries. Conforming adds additional overhead as it must conform the query results with unit of work changes and new and deleted objects.

For CMP, the default is ConformResultsInUnitofWork. To avoid conforming, normally you can change this to CheckCacheByPrimaryKey; for read-all queries this basically means the same as DoNotCheckCache.

Default: ConformResultsInUnitofWork

Turn Cache Usage Conform off if you do not need uncommitted data read in your transaction, especially for read-only operations, in each descriptor and at the query level if not needed.

Isolation

There is not a single tuning parameter that sets a particular database transaction isolation level in a CMP application that uses TopLink. In a typical CMP application, a variety of factors affect when database transaction isolation levels apply and to what extent a particular database transaction isolation can be achieved, including the following:

  • Locking mode

  • Use of the Session Cache

  • External Applications

  • Database Login method setTransactionIsolation

See Also: Oracle TopLink Developer's Guide section, "Database Transaction Isolation Levels"


Cache Refreshing

By default, TopLink caches objects read from a data source. Subsequent queries for these objects access the cache and thus improve performance by reducing data source access and avoiding the cost of rebuilding object's and their relationships. Even if a query, such as a read-all query, accesses the data source, if the objects corresponding to the records returned are in the cache, TopLink uses the cached objects. This default caching policy can lead to stale data in the application.

Refreshing can be enabled at the descriptor level (alwaysRefreshCache) and the query level (refreshIdentityMapResult). If set at the descriptor level primary-read-object queries will still get cache hits unless you also set (disableCacheHits).Using an appropriate locking policy is the only way to ensure that stale or conflicting data does not get committed to the database. Thus, there are a few cases to consider for data refreshing in the cache, all with performance implications:

  • In the case where you never want cached data and always want fresh data, we recommend using an isolated cache. This is the case when certain data in the application changes so frequently that it is desirable to always refresh the data, instead of only refreshing the data when a conflict is detected.

  • In the case when you want to avoid stale data, but getting stale data is not a major issue, then using a cache-invalidation policy would be the recommended solution. In this case you should also use optimistic locking, and typically also need a method to refresh stale objects when a locking error occurs. In this case you need to define a finder such as findAndRefreshByPrimaryKey that had (refreshIdentityMapResult) set to force refreshing of the object. If using optimistic locking you could also enable alwaysRefreshCache and onlyRefreshCacheIfNewerVersion to allow queries that access the database to refresh any stale objects returned, and avoid refreshing invalid objects when unchanged. You may also want to enable refreshing on certain finder operations when you know you want refreshed data, or even provide the option of refreshing something from the client that would call a refreshing finder.

  • In the case when you are not concerned about stale data.

    In this case you should use optimistic locking and also write an error handler to commit operations to refresh stale objects on locking errors.

Default: No Cache Refreshing

See Also: Oracle TopLink Developer's Guide section, "Configuring Cache Refreshing"

Try to avoid descriptor level cache refresh and instead, consider configuring the following:

  • cache refresh on a query-by-query basis

  • cache expiration

  • isolated caching



Note:

By default, TopLink assumes that your application has exclusive access to the data it is using (that is, there are no external, nonTopLink, applications modifying the data). If your application does not have exclusive access to the data, then you need to change some of the defaults from Table 4-5.

The default settings for CMP2.1 used with the TopLink persistence manager and cache are no locking, no cache refresh, and cache-usage conform. To assure that your application doesn't read stale data from the cache when you don't have exclusive access, and gets the required data consistency level, you need to configure these and other isolation related settings appropriately.

The locking modes, as shown in Table 4-6, along with TopLink cache-usage and query refreshing options, assures data consistency for EJB entity beans using CMP. The different combinations have both functional and performance implications, but often the functional requirements for up-to-date data and data consistency will lead to the settings for these options, even when it may be at the expense of performance.

Table 4-6 Locking Policies

Locking Option Description Performance Notes

No Locking

The application does not prevent users overwriting each other's changes. This is the default locking mode.Use this mode if the Bean is never updated concurrently or concurrent reads and updates to the same rows with read-committed semantics is sufficient.

See Also: Oracle TopLink Developer's Guide sections, "Configuring Locking Policy" and "Understanding Descriptors and Locking"

In general, no locking will be faster, but may not meet your needs for data consistency

Optimistic

All users have read access to the data. When a user attempts to make a change, the application checks to ensure the data has not changed since the user read the data.

See Also: Oracle TopLink Developer's Guide sections, "Configuring Locking Policy" and "Understanding Descriptors and Locking"


Pessimistic

The first user who accesses the data with the purpose of updating it locks the data until completing the update.

See Also: Oracle TopLink Developer's Guide sections, "Configuring Locking Policy" and "Understanding Descriptors and Locking"

If frequent concurrent updates to the same rows are expected, pessimistic locking may be faster than optimistic locking that is getting a lot of concurrent access exceptions and retries. When using pessimistic locking at the bean level, it is recommended that you use it with an isolated cache for best performance

Read Only

Setting a CMP bean descriptor to read-only ensures that the entity bean cannot be modified and allows TopLink to optimize unit of work performance.

See Also: Oracle TopLink Developer's Guide sections, "Configuring Locking Policy" and "Understanding Descriptors and Locking"

Defining a bean as read-only will perform better than a bean that is not defined as read-only, yet does no inserts, updates, or deletes, since it allows TopLink to optimize the unit of work performance.


4.3.2.3 Monitoring CMP Resources

Check the DMS metric table type named oc4j_ejb_method and the metrics wrapper.avg or client.avg to see if your EJB methods are taking significant time (check for unexpectedly large values, as some methods you may expect to take a long time to complete). For example, check the metric values for the methods ejbCreate, create, findAll, or your application specific EJB methods.

You can also check the metrics that Application Server Control Console provides to see how the response times and transactions per second are changing over time, as follows:

  1. From the OC4J home page, select the Applications secondary tab.

  2. In the table, under All Applications, select the application that you want to monitor.

  3. In the Modules table, select the EJB module of that you want to monitor.

You can also view CMP TopLink metrics for additional information on CMP performance.


Note:

You need to set the DMS configuration OC4J command line-property -Doracle.dms.sensors to the value Heavy or All to turn on collection of TopLink related DMS metrics.


See Also: