Sun GlassFish Enterprise Server v2.1.1 Performance Tuning Guide

Monitoring EJB Components

When the EJB container has monitoring enabled, you can examine statistics for individual beans based on the bean pool and cache settings.

For example, the monitoring command below gives the Bean Cache statistics for a stateful session bean.

asadmin get --user admin --host e4800-241-a --port 4848 
-m specjcmp.application.SPECjAppServer.ejb-module.
   supplier_jar.stateful-session-bean.BuyerSes.bean-cache.*

The following is a sample of the monitoring output:

resize-quantity = -1
 cache-misses = 0
 idle-timeout-in-seconds = 0
 num-passivations = 0
 cache-hits = 59
 num-passivation-errors = 0
 total-beans-in-cache = 59
 num-expired-sessions-removed = 0
 max-beans-in-cache = 4096
 num-passivation-success = 0

The monitoring command below gives the bean pool statistics for an entity bean:

asadmin get --user admin --host e4800-241-a --port 4848 
-m specjcmp.application.SPECjAppServer.ejb-module.
   supplier_jar.stateful-entity-bean.ItemEnt.bean-pool.* 
idle-timeout-in-seconds = 0 
steady-pool-size = 0 
total-beans-destroyed = 0 
num-threads-waiting = 0 
num-beans-in-pool = 54 
max-pool-size = 2147483647 
pool-resize-quantity = 0 
total-beans-created = 255

The monitoring command below gives the bean pool statistics for a stateless bean.

asadmin get --user admin --host e4800-241-a --port 4848 
-m test.application.testEjbMon.ejb-module.slsb.stateless-session-bean.slsb.bean-pool.*
idle-timeout-in-seconds = 200
steady-pool-size = 32
total-beans-destroyed = 12
num-threads-waiting = 0
num-beans-in-pool = 4
max-pool-size = 1024
pool-resize-quantity = 12
total-beans-created = 42

Tuning the bean involves charting the behavior of the cache and pool for the bean in question over a period of time.

If too many passivations are happening and the JVM heap remains fairly small, then the max-cache-size or the cache-idle-timeout-in-seconds can be increased. If garbage collection is happening too frequently, and the pool size is growing, but the cache hit rate is small, then the pool-idle-timeout-in-seconds can be reduced to destroy the instances.


Note –

Specifying a max-pool-size of zero (0) means that the pool is unbounded. The pooled beans remain in memory unless they are removed by specifying a small interval for pool-idle-timeout-in-seconds. For production systems, specifying the pool as unbounded is NOT recommended.


Monitoring Individual EJB Components

To gather method invocation statistics for all methods in a bean, use this command:

asadmin get -m monitorableObject.*

where monitorableObject is a fully-qualified identifier from the hierarchy of objects that can be monitored, shown below.

serverInstance.application.applicationName.ejb-module.moduleName

where moduleName is x_jar for module x.jar.

For standalone beans, use this pattern:

serverInstance.application.applicationName.standalone-ejb-module.moduleName

The possible identifiers are the same as for ejb-module.

For example, to get statistics for a method in an entity bean, use this command:

asadmin get -m serverInstance.application.appName.ejb-module.moduleName
.entity-bean.beanName.bean-method.methodName.*

To find the possible objects (applications, modules, beans, and methods) and object attributes that can be monitored, use the Admin Console. For more information, see Chapter 18, Monitoring Components and Services, in Sun GlassFish Enterprise Server v2.1.1 Administration Guide. Alternatively, use the asadmin list command. For more information, see list(1).

For statistics on stateful session bean passivations, use this command:

asadmin get -m serverInstance.application.appName.ejb-module.moduleName
.stateful-session-bean.beanName.bean-cache.*

From the attribute values that are returned, use this command:

num-passivationsnum-passivation-errorsnum-passivation-success