Shrinking a Connection Pool
JDBCConnectionPoolRuntimeMBean.shrink()
A connection pool has a set of properties that
define the initial and maximum number of connections in the pool
(initialCapacity and maxCapacity),
and the number of connections added to the pool when all connections are in use (capacityIncrement).
When the pool reaches its maximum capacity,
the maximum number of connections are opened,
and they remain opened unless you enable automatic shrinking
on the connection pool or manually shrink the connection pool
with the shrink() method.
You may want to drop some connections from the connection pool
when a peak usage period has ended,
freeing up WebLogic Server and DBMS resources.
This system resource usage service is turned on by default.
However, to turn off this service,
you can set the shrinking-enabled element in the weblogic-ra.xml descriptor file to false.
Use the shrink-frequency-seconds element in the weblogic-ra.xml descriptor file to
identify the amount of time (in seconds)
that the Connection Pool Management will wait between attempts to reclaim unused Managed Connections.
The default value of this element is 900 seconds.
For more information about these elements
<shrinking-enabled>
Optional Indicates whether or not the connection pool should
have unused managed connections reclaimed
as a means to control system resources.
Failure to specify this value will result in
WebLogic Server using its defined default value.
Value Range: true | false
Default Value: true
<shrink-frequency-seconds>
Optional Indentifies the amount of time (in seconds)
that Connection Pool Management will wait
between attempts to reclaim unused Managed Connections.
Failure to specify this value will result in
Weblogic using its defined default value.
Default Value: 900 seconds
How JDBC Connection Pools Enhance Performance
Establishing a JDBC connection with a DBMS can be very slow.
If your application requires
database connections that are repeatedly opened and closed,
this can become a significant performance issue.
WebLogic connection pools offer an efficient solution to the problem.
When WebLogic Server starts,
connections from the connection pools are opened and are available to all clients.
When a client closes a connection from a connection pool,
the connection is returned to the pool and becomes available for other clients;
the connection itself is not closed.
There is little cost to opening and closing pool connections.
How many connections should you create in the pool?
A connection pool can grow and shrink according to configured parameters,
between a minimum and a maximum number of connections.
The best performance occurs
when the connection pool has as many connections as there are concurrent client sessions.
shrinking-enabled—Optional.
The shrinking-enabled element indicates
whether or not the pool can shrink back to its initial-capacity
when connections are detected to not be in use.
shrink-period-minutes—Optional.
The shrink-period-minutes element defines
the number of minutes to wait before shrinking a connection pool
that has incrementally increased to meet demand.
The shrinking-enabled element must be set to true
for shrinking to take place.
Controlling System Resource Usage
Although setting the maximum number of ManagedConnections
prevents the server from becoming overloaded
by more allocated ManagedConnections than it can handle,
it does not control the efficient amount of system resources needed at any given time.
WebLogic Server provides a service that monitors the activity of ManagedConnections
in the connection pool of a resource adapter.
If the usage decreases and remains at this level over a period of time,
the size of the connection pool is reduced to an efficient amount necessary
to adequately satisfy ongoing connection requests.