Server Open Source Edition 3. 1 comes
with reasonable settings, so we can reduce the maximum number of connections from the Derby pool to two connections to simulate a bottleneck. With
five concurrent threads (users) and only
two database connections, there should
be some contention (see Figure 7).
The performance is still surprisingly
good. We get 1,400 transactions per
second with two connections. The max
response time went up to 60 seconds,
which correlates surprisingly well with
the “Max Wait Time: 60000 ms” connection pool setting in GlassFish Server
Open Source Edition 3. 1. A hint in the
log files also points to the problem, as
shown in Listing 2.
Also interesting is the Sampler view in
VisualVM (see Figure 8).
The method
JNDIConnector.connect()
became the most expensive method.
It even displaced the
Reply.fill() method
from its first rank.
The package
org.eclipse.persistence
is the JPA provider for GlassFish Server
Open Source Edition 3. 1, so it should
give us a hint about the bottleneck’s
location. There is nothing wrong with
the persistence layer; it only has to wait
for a free connection. This contention is
caused by the artificial limitation of having only two connections available for
five virtual users.
A look at the
JNDIConnector.connect
method confirms our suspicion (see
Listing 3). In the method JNDIConnect
.connect, a connection is acquired from a
DataSource. In the case of an empty pool,
the method will block until either an
WARNING: RAR5117 : Failed to obtain/create connection from connection pool
[ SamplePool ]. Reason : com.sun.appserv.co
nnectors.internal.api.PoolingException:
In-use connections equal max-pool-size and expired max-wait-time. Cannot allocate
more connections.
WARNING: RAR5114 : Error allocating connection : [Error in allocating a connection.
Cause: In-use connections equal max-pool-size and expired max-wait-time. Cannot
allocate more connections.]
COMMUNITY
JAVA IN ACTION
See all listings as text
in-use connection becomes free or the
Max Wait Time is reached. The method
can block up to 60 seconds with the
GlassFish Server Open Source Edition
default settings. This rarely happens
with the default settings, because the
server ships with a Maximum Pool Size
of 32 database connections.
ABOUT US
Figure 7
blog
Figure 8
How to Get the Interesting Stuff
The combination of JMeter and
VisualVM is useful for ad hoc measurements. In real-world projects, stress
tests should be not only repeatable but
also comparable. A history of results
with visualization makes the resultant comparison and identification of
hotspots easier.
VisualVM provides a good overview,
but the really interesting monitoring
information can be obtained only from
an application server in a proprietary
way. All major application servers provide extensive monitoring information
via Java Management Extensions (JMX).
GlassFish Server Open Source Edition
3. 1 exposes its monitoring and management data through an easily accessible Representational State Transfer
(REST) interface.
To activate the monitoring, open the
GlassFish Admin Console by specifying
the Admin Console URI (http://
localhost:4848). Then select Server,
select Monitor, and then select Configure
Monitoring. Then select the HIGH level
for all components. Alternatively, you can
activate monitoring by using the asadmin
command from the command line or by
using the REST management interface.
Now, all the monitoring information is
accessible from the following root URI:
http://localhost:4848/monitoring/
domain/server. The interface is self-explanatory. You can navigate through
the components from a browser or from
the command line.
The command curl -H "Accept:
application/json" http://localhost:4848/
monitoring/domain/server/jvm/memory/