Tomcat Datasources Test

A data source is an object that enables a Java Database Connectivity (JDBC) client, such as an application server, to establish a connection with a database. A connection pool is a factory for getting connections to different physical data sources.

If a connection pool does not have enough idle/unused connections, Tomcat may not be able to entertain database connection requests from applications. This in turn can significantly degrade application performance. The presence of too many idle connections in a pool can also adversely impact application performance, as such connections are avoidable resource hogs!

To ensure peak performance of Tomcat applications at all times, administrators have to make sure that the connection pools are sized according to their usage. By providing administrators with actionable information on the usage and configuration of each pool, the Tomcat Datasources test rapidly turns user attention to pools that are incorrectly sized and could hence be a threat to application performance. This way, the test urges administrators to right-size pools, so that application-database interaction is not interrupted.

Target of the test : A Tomcat Server

Agent deploying the test : An internal agent

Outputs of the test : One set of results for every connection pool configured on the Tomcat server being monitored.

Configurable parameters for the test
Parameter Description

Test Period

How often should the test be executed.

Host

The IP address of the host for which this test is to be configured.

Port

Refers to the port at which the specified host listens to.

Measurement Mode

This test can extract metrics from Tomcat using either of the following mechanisms:

  • By deploying the egtomcat.war file in the <EG_INSTALL_DIR>\lib directory of the eG agent host on the Tomcat server;
  • By contacting the Java runtime (JRE) of Tomcat via JMX

To configure the test to use egtomcat.war file, first select the War file option. Then, refer to the How Does eG Enterprise Monitor Tomcat Servers? to know how to deploy the WAR file on the target Tomcat server.

On the other hand, if you want the test to use JMX instead, then first, select the JMX option. Then, follow the procedure detailed in the How Does eG Enterprise Monitor Tomcat Servers? to configure the test to use jmx. By default, the JMX option is chosen here.

JMX Remote Port

This parameter appears only if the Measurement Mode is set to JMX. Here, specify the port at which the JMX listens for requests from remote hosts. Ensure that you specify the same port that you configured in the catalina.sh (or catalina.bat) file in the <CATALINA_HOME_DIR>/bin folder of the target Tomcat server (refer to the How Does eG Enterprise Monitor Tomcat Servers? for more details).

JMX User, JMX Password, and Confirm Password

These parameters appear only if the Measurement Mode is set to JMX. If JMX equires authentication only (but no security), then ensure that the JMX User and JMX Password parameters are configured with the credentials of a user with read-write access to JMX. To know how to create this user, refer to the How Does eG Enterprise Monitor Tomcat Servers?. Confirm the password by retyping it in the Confirm Password text box.

JNDI Name

This parameter appears only if the Measurement Mode is set to JMX. The JNDIName is a lookup name for connecting to the JMX connector. By default, this is jmxrmi. If you have registered the JMX connector in the RMI registery using a different lookup name, then you can change this default value to reflect the same. 

Provider

This parameter appears only if the Measurement Mode is set to JMX. This test uses a JMX Provider to access the MBean attributes of the target Java application and collect metrics. Specify the package name of this JMX Provider here. By default, this is set to com.sun.jmx.remote.protocol.

SSL

This parameter appears only if the Measurement Mode is set to War File. Indicate Yes if the Tomcat server is SSL-enabled.

URL

This parameter appears only if the Measurement Mode is set to War File. Specify the URL of the managed Tomcat server to enable the test to connect to it and extract measures from it. The URL specification should be of the format: http://{TomcatIP}:{TomcatPort}.

UserName, Password, and Confirm Password

These parameters appear only if the Measurement Mode is set to War File. In the UserName text box, specify a name of a user who has been assigned the Manager role on the Tomcat server to be monitored; these users are typically allowed to control web applications deployed on the Tomcat server. Specify the Password of this user, and confirm the password by retyping it in the Confirm Password text box.

EncryptPass

This parameter appears only if the measurement modeis set to War File. Select Yes if you want to encrypt the password.

Timeout

Specify the duration (in seconds) for which this test should wait for a response from Tomcat. If there is no response from Tomcat beyond the configured duration, the test will timeout. By default, this is set to 240 seconds.

Measurements made by the test
Measurement Description Measurement Unit Interpretation

Initial connections

Indicates the number of connections that were open at this pool's start-up.

Number

 

No of active connections

Indicates the number of established connections in this pool that are in use currently.

Number

 

Idle connections

Indicates the number of idle connections in this pool.

Number

 

Max no of idle connections

Reports the maximum number of idle connections that this pool can contain.

Number

When configuring a connection pool using the server.xml file, a maxIdle parameter is typically set. This measure reports the value set for the maxIdle parameter.

If this value is consistently close to or equal to the value of the Idle connections measure of a pool, then it means that there are too many idle connections in that pool. As idle connections are a resource drain, it is best to keep them at a minimum. So, you may want to reduce the maxIdle configuration of that pool. Doing so will ensure that the pool drops all idle connections in excess of the configured maxIdle value, thereby reducing the risk of excessive resource consumption.

Min no of idle connections

Reports the minimum number of idle connections that should be present in this pool at any given point in time.

Number

Ideally, this value should be equal to or greater than the value of the Idle connections measure.

Max total connections

Indicates the maximum number of established connections that this pool can contain.

Number

Ideally, the value of this measure should be greater than or equal to the sum of the values of the No of active connections measure and Idle connections measure.

Datasource type

Indicates the type of this pool.

 

The values that this measure can report and their corresponding numeric values are listed below:

Measure Value Numeric Value
DBCP 0
Tomcat JDBC 1
Druid 2
Hikari 3

C3P0

4

BoneCP

5

Note:

By default, this measure reports the Measure Values listed in the table above to indicate the data source type. In the graph of this measure however, the same is indicated using the numeric equivalents only.

Percent of idle connections

Indicates the percentage of maximum connections that are actually idle in this pool.

Percent

If the value of this measure is over 50%, it implies that more than half of the maximum number of connections a pool can have are currently idle. While its good to have adequate idle connections in a pool, if there are too many idle connections, server resources may be unnecessarily drained. To avoid this, its best to limit the number of idle connections a pool can have using the maxIdle setting in the server.xml file.

Percent of active connections

Indicates the percentage of maximum connections that are actively used in this pool.

Percent

If the value of this measure is close to 100%, it is cause for concern. This is because, it implies that there are hardly any idle connections in the pool. Without sufficient idle connections, a pool may not be able to service connection requests. As a result, applications may not be able to interact with the database backend, which in turn can adversely impact application performance. This is why, ideally, the value of this measure should be low.

Available connections

Indicates the number of connections that are neither used nor idle.

Number

This measure is computed using the following formula:

Max total connections (-) No of active connections (-) Idle connections

Percent of available connections

Indicates the percentage of connections that are neither used nor idle.

Percent

This measure is the value of the Available connections measure expressed as a percentage.