Figure 1
with the current JDK, you should check
the VisualVM Website for updates.
VisualVM is able to connect locally or
remotely to a Java process and monitor
it. VisualVM provides an overview showing CPU load, memory consumption,
number of loaded classes, and number
of threads, as shown in Figure 3.
The overview is great for estimating resource consumption and monitoring the
overall stability of the system. We learn
from Figure 3 that for 1,700 transactions
per second, GlassFish Server Open Source
Edition 3. 1 needs 58 MB for the heap,
67 threads, and about 50 percent of the
CPU. The other 50 percent was consumed by the load generator (JMeter).
Although this colocation is adequate
for the purposes of this article, it blurs
the results. The load generator should
run on a dedicated machine or at least
in an isolated (virtual) environment.
Sometimes, you even have to run
distributed JMeter load tests to generate enough load to stress the server. For
internet applications, it might be necessary to deploy the load generators into
the cloud.
In a stress test scenario, the plain
numbers are interesting but unimportant. Stress tests do not generate a
realistic load, but rather they try to break
the system. To ensure stability, you
should monitor the VisualVM Overview
COMMUNITY
JAVA IN ACTION
Figure 2
The open source load testing tool
Apache JMeter comes with built-in HTTP
support. After creating the ThreadGroup
and setting the number of threads (and,
thus, concurrent users), an HTTP
request has to be configured to execute
the GET requests (right-click, select
Sampler, and then select HTTP Request).
See Figure 1.
While the results can be visualized
in various ways, the JMeter Summary
Report is a good start (see Figure 2). It
turns out that the sample application
is able to handle 1,700 transactions per
second for five concurrent users out of
the box.
Every request is a true transaction
and is processed by an Enterprise
JavaBeans 3. 1 (EJB 3. 1) JAX-RS
PredictionArchiveResource, delegated to
the PredictionAudit EJB 3. 1 bean, which
in turn accesses the database through
EntityManager (with exactly one record).
ABOUT US
VisualVM Turns Night to Day
GlassFish Server Open Source Edition
3. 1.x and Java DB (the open source
version of Apache Derby) are Java processes that can be easily monitored with
VisualVM. Although VisualVM is shipped
blog
Figure 3