Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Performance Tuning Guide

- Previous: Monitoring JDBC Connection Pools
- Next: Connector Connection Pool Settings

### Tuning JDBC Connection Pools

Set JDBC Connection Pool attributes with the Admin Console under Resources > JDBC > Connection Pools > PoolName. The following attributes affect performance:

- Pool Size Settings

- Timeout Settings

- Isolation Level Settings

- Connection Validation Settings

#### Pool Size Settings

The following settings control the size of the connection pool:

Initial and Mimimum Pool Size

  Size of the pool when created, and its minimum allowable size.

Maximum Pool Size

  Upper limit of size of the pool.

Pool Resize Quantity

  Number of connections to be removed when the idle timeout expires. Connections that have idled for longer than the timeout are candidates for removal. When the pool size reaches the initial and minimum pool size, removal of connections stops.

The following table summarizes pros and cons to consider when sizing connection pools.

Table 3–5 Connection Pool Sizing

Connection pool | Pros | Cons
--- | --- | ---
Small Connection pool | Faster access on the connection table. | May not have enough connections to satisfy requests. Requests may spend more time in the queue.
Large Connection pool | More connections to fulfill requests. Requests will spend less (or no) time in the queue | Slower access on the connection table.

#### Timeout Settings

There are two timeout settings:

- Max Wait Time: Amount of time the caller (the code requesting a connection) will wait before getting a connection timeout. The default is 60 seconds. A value of zero forces caller to wait indefinitely.

  To improve performance set Max Wait Time to zero (0). This essentially blocks the caller thread until a connection becomes available. Also, this allows the server to alleviate the task of tracking the elapsed wait time for each request and increases performance.

- Idle Timeout: Maximum time in seconds that a connection can remain idle in the pool. After this time, the pool can close this connection. This property does not control connection timeouts on the database server.

  Keep this timeout shorter than the database server timeout (if such timeouts are configured on the database), to prevent accumulation of unusable connection in Application Server.

  For best performance, set Idle Timeout to zero (0) seconds, so that idle connections will not be removed. This ensures that there is normally no penalty in creating new connections and disables the idle monitor thread. However, there is a risk that the database server will reset a connection that is unused for too long.

#### Isolation Level Settings

Two settings control the connection pool’s transaction isolation level on the database server:

- Transaction Isolation Level: specifies the transaction isolation level of the pooled database connections. If this parameter is unspecified, the pool uses the default isolation level provided by the JDBC Driver.

- Isolation Level Guaranteed: Guarantees that every connection obtained from the pool has the isolation specified by the Transaction Isolation Level parameter. Applicable only when the Transaction Isolation Level is specified. The default value is true.

  This setting can have some performance impact on some JDBC drivers. Set to false when certain that the application does not change the isolation level before returning the connection.

Avoid specifying Transaction Isolation Level. If that is not possible, consider setting Isolation Level Guaranteed to false and make sure applications do not programmatically alter the connections’ isolation level.

If you must specify isolation level, specify the best-performing level possible. The isolation levels listed from best performance to worst are:

1. READ_UNCOMMITTED

2. READ_COMMITTED

3. REPEATABLE_READ

4. SERIALIZABLE

Choose the isolation level that provides the best performance, yet still meets the concurrency and consistency needs of the application.

#### Connection Validation Settings

The following settings determine whether and how the pool performs connection validation.

Connection Validation Required

  If true, the pool validates connections (checks to find out if they are usable) before providing them to an application.

  If possible, keep the default value, false. Requiring connection validation forces the server to apply the validation algorithm every time the pool returns a connection, which adds overhead to the latency of `getConnection()`. If the database connectivity is reliable, you can omit validation.

Validation Method

  Type of connection validation to perform. Must be one of:

  - auto-commit: attempt to perform an auto-commit on the connection.

  - metadata: attempt to get metadata from the connection.

  - table (performing a query on a specified table). Must also set Table Name. You may have to use this method if the JDBC driver caches calls to `setAutoCommit()` and `getMetaData()`.

Table Name

  Table name to query when Validation Method is “table.”

Close All Connections On Any Failure

  Whether to close all connections in the pool if a single validation check fails. The default is false. One attempt will be made to re-establish failed connections.

- Previous: Monitoring JDBC Connection Pools
- Next: Connector Connection Pool Settings

- © 2010, Oracle Corporation and/or its affiliates