Tuning the cache size

Connection caches have 10 connections by default. For applications with many clients, this number is often too small. For lightly used caches, you can lower the size to free up memory and network connections that would be wasted by rarely used database connections. To tune the cache size, monitor the cache statistics as described in Chapter 11, “Runtime Monitoring,” in the EAServer System Administration Guide. Tune the cache size by setting the properties listed in Table 6-1.

Table 6-1: Properties to configure connection cache size

Property

Description

Minimum Connection Pool Size

The minimum number of pooled connections, allocated at server start-up. If not set, the default is 0.

With jagtool, you can set as com.sybase.jaguar.conncache.poolsize.min.

Maximum Connections

The absolute maximum number of connections that can be created from the cache. Requests for excess connections either block or fail. A value of 0 indicates that there is no limit.

With jagtool, you can set as com.sybase.jaguar.conncache.poolmanager.maxconnection.

Maximum Connection Pool Sizes

The maximum number of connections that can be cached. If connections are allocated beyond this number, the cache manager drops the excess connections when they are released.

With jagtool, you can set as com.sybase.jaguar.conncache.poolsize.max.

Wait for Connections

When the maximum connections limit is reached, specifies whether requests for excess connections fail immediately or wait until a connection is released. If this setting is enabled, the request waits.

With jagtool, you can set as com.sybase.jaguar.conncache.wait.

Pooled Connection Idle Timeout

Specifies the number of seconds an idle connection remains in the pool before it is dropped. The default is 300 seconds (5 minutes). Idle connections are dropped until the minimum pool size is reached.

NoteIf the minimum connection pool size is set to 0, connections are not dropped.

To disable the monitoring of idle connections, set to a negative value. For more information, see “Disabling the cache size monitor thread”.

With jagtool, you can set as com.sybase.jaguar.conncache.idletimeout.

Pooled Connection Refresh Rate

The refresh rate for the cache, that is, how often the cache manager checks for excess connections that have been idle longer than the idle timeout period. The default is 600 seconds (10 minutes).

To disable the monitoring of idle connections, set to a negative value. For more information, see “Disabling the cache size monitor thread”.

With jagtool, you can set as com.sybase.jaguar.conncache.refreshrate.

Set the pool size so the majority of database connections are taken from the cache. You can tune the minimum pool size and refresh rate parameters to reduce the number of database connections that are held during off-peak hours. You can raise the maximum size if you see many failed connection requests or waits.

Figure 6-1 illustrates how these settings affect the growth of the connection cache.

Figure 6-1: Connection cache growth patterns

When the server starts, it preallocates the minimum number of connections, allowing faster response times to the initial client requests that require a database connection.

If all connections are in use simultaneously, the cache manager creates new connections. When released, these connections are added to the cache, causing it to grow towards its maximum pool size.

During peak use, additional connections may be required beyond the maximum pool size, up to the absolute maximum. When these excess connections are released, they are closed rather than placed in the cache. Setting an absolute maximum prevents your application from overwhelming the database with too many connections or exceeding database license limits. You can set the Wait for Connections setting to determine what happens when your application asks for connections in excess of the absolute maximum size. You can also set the absolute maximum to 0 to indicate no limit.

NoteWhen many connections are created in excess of the maximum pool size, you may see a drop in performance. You may also see a drop in performance if excess, unpooled connections are rapidly created and destroyed to service short transactions. To avoid these scenarios, raise the maximum pool size.

When the activity level drops, the cache manager removes idle connections if you have configured a refresh rate and idle connection limit. If there is no activity, the cache size drops back down to the minimum.