
EJB Performance Tuning
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 2.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
From the attribute values that are returned, use this command:
General Guidelines
The following guidelines can improve performance of EJB components. Keep in mind that decomposing an application into many EJB components creates overhead and can degrade performance. EJB components are not simply Java objects. They are components with semantics for remote call interfaces, security, and transactions, as well as properties and methods.
Use High Performance Beans
Use
The types of EJB components are listed below, from the highest performance to the lowest:
1.Stateless Session Beans and Message Driven Beans
2.Stateful Session Beans
3.Container Managed Persistence (CMP) entity beans configured as
4.Bean Managed Persistence (BMP) entity beans configured as
5.CMP beans
6.BMP beans
Use Caching
Caching can greatly improve performance when used wisely. For example:
■Cache EJB references: To avoid a JNDI lookup for every request, cache EJB references in servlets.
■Cache home interfaces: Since repeated lookups to a home interface can be expensive, cache references to EJBHomes in the init() methods of servlets.
Chapter 2 • Tuning Your Application | 35 |