Measuring performance
... Logo
The latest version of Proxool is 0.9.1
You can donate to Proxool in the usual way:

You can configure Proxool to collect statistics about how it is performing. You do this by setting the statistics property. For example, using the XML configurator a fragment of the XML might look like this:


The statistics value is tokenized into three separate sets: '1m', '15m' and '1d'. These refer to the period between samples. The units are: s(econds), m(inutes), h(ours) and d(ays). So in this example, Proxool will take samples every minute, every 15 minutes and every day.

There are a four ways to access this information:

1. AdminServlet. If you are using a web application that supports Java Servlets then you can configure your app to use this servlet. It gives you all sorts of information (see AdminServlet). An example configuration would be:



2. Ask for statistics and snapshots in your code. This is basically what the AdminServlet does. You can do exactly the same and present the information in whatever way you want.

// Get back an array of all the statistics for a particular pool
StatisticsIF[] statisticsArray = ProxoolFacade.getStatistics(alias);

So, in our example above, a statistics setting of "1m,15m,1d" would mean that this method would return 3 elements. See StatisticsIF in the API. You can also ask for each one explicitly:

// Get back one single set of statistics
String token = "15m";
StatisticsIF statistics = ProxoolFacade.getStatistics(alias, token);

A snapshot is information about the pool for a single point in time:

// Get a snapshot
SnapshotIF snapshot = ProxoolFacade.getSnapshot(alias, true);

The true parameter means get a detailed snapshot. That is information about what each individual connection is doing: whether it is active, the name of the thread that used it, how long it was active for, etc.. See SnapshotIF in the API.

3. Listen for statistics. By registering a listener you will receive statistics as soon as they are produced:

StatisticsListenerIF myStatisticsListener = new MyStatisticsListener();

class MyStatisticsListener implements StatisticsListenerIF {
  public void statistics(String alias, StatisticsIF statistics) {
    // Do whatever you want

4. Just use the log. The log outputs statistics in the following format:

16:17:55 - 16:18:00, s:17:3.40/s, r:0:0.00/s, a:9ms/0.30

This means that the statistics apply to the time from 16:17:55 to 16:18:00 (5 seconds). In that time we served 17 connections (at 3.40 per second) and refused none. The average time each connection was active was 9ms and, on average, 0.3 connections were active at any one time.