Connection Pool Monitoring
Introduction
This page documents how the Mifos built-in Connection Pool to the mySQL Database can be monitored at run-time. This can be needed and useful to e.g. simply keep an eye on DB Connections, or to troubleshoot when issues such as connection exhaustion arise, and a connection leak may be suspected.
Connection Pooling in Mifos uses the c3p0 library (via Hibernate). c3p0 supports JMX for monitoring out of the box.
The Java 6 JDK includes "Java Visual VM" (successor of the JConsole from Java v5), a nice monitoring console for JVMs which out of the box displays trends for CPU, Heap & PermGen memory usage, Class loading, and Threads details (including a "Thread Dump" button which is a GUI alternative to the Ctrl-Break on Windows or kill -3 on *NIX). Visual VM is, via an optional plug-in, also a JMX Console.
Step by step instructions
- Ensure you have a Java 6 JDK available where Mifos is running, or download and install it from if not. (Note that Mifos can still RUN on a JRE, if that is how it was set-up, but the Java Visual VM is only available in the JDK and not the JRE.)
- Start e.g. jvisualvm.exe from your %JDK_HOME%\bin directory
- Menu Tools > Plug-Ins, in Tab Available Plug-Ins, check VisualVM-MBeans (unless it's already in the Installed Tab)
- restart VisualVM for the plug-in to be activated
- Menu Windows > Applications, under Local, the Mifos process should appear, double-click it
- MBeans Tab should have an com.mchange.v2.c3p0 MBean, under which PooledDataSource will be available, and Attributes will show configuration and current state
- Double-clicking on e.g. the numConnections attribute will plot the variable
Note that due to MIFOS-4369 Mifos currently (time of writing) creates & uses two independent connection pools internally - one for the normal application / HTTP requests, and one for the batch background jobs.
Visual VM may also be useful unrelated to connection pooling to simply monitor the Mifos JVM's CPU load, Garbage Collection activity, and Heap & PermGen memory usage:
References
- JDK (incl. Visual VM) download from http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Visual VM JMX documentation at http://visualvm.java.net/mbeans_tab.html & http://visualvm.java.net/jmx_connections.html
- http://mifosforge.jira.com/browse/MIFOS-5100 would provide a Web-based & REST-enabled Monitoring console in Mifos
- http://static.springsource.org/spring/docs/current/reference/jmx.html documents how any Mifos Spring bean could easily be exposed via JMX
- MC4j is a fat client JMX Monitoring console fairly similar to JVisualVM: http://sourceforge.net/projects/mc4j/
- Nagios from http://www.nagios.org is a full-fledge Monitoring tool, which supports JMX as well and could be used for this too
- JRockit Mission Control from http://www.oracle.com/technology/products/jrockit/missioncontrol/index.html appears to be a more powerful alternative to Java Visual VM (but needs the alternative JRockit VM?)