Server User Manual
Table Of Contents
- Sun GlassFish Enterprise Server 2.1 Performance Tuning Guide
- Preface
- Overview of Enterprise Server Performance Tuning
- Tuning Your Application
- Java Programming Guidelines
- Java Server Page and Servlet Tuning
- EJB Performance Tuning
- Goals
- Monitoring EJB Components
- General Guidelines
- Using Local and Remote Interfaces
- Improving Performance of EJB Transactions
- Use Container-Managed Transactions
- Don’t Encompass User Input Time
- Identify Non-Transactional Methods
- Use TX_REQUIRED for Long Transaction Chains
- Use Lowest Cost Database Locking
- Use XA-Capable Data Sources Only When Needed
- Configure JDBC Resources as One-Phase Commit Resources
- Use the Least Expensive Transaction Attribute
- Using Special Techniques
- Tuning Tips for Specific Types of EJB Components
- JDBC and Database Access
- Tuning Message-Driven Beans
- Tuning the Enterprise Server
- Deployment Settings
- Logger Settings
- Web Container Settings
- EJB Container Settings
- Java Message Service Settings
- Transaction Service Settings
- HTTP Service Settings
- ORB Settings
- Thread Pool Settings
- Resources
- Tuning the Java Runtime System
- Tuning the Operating System and Platform
- Tuning for High-Availability
- Index

To nd 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 -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
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 high-performance beans as much as possible to improve the overall performance of your
application. For more information, see “Tuning Tips for Specic Types of EJB Components” on
page 42
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 congured as read-only
4. Bean Managed Persistence (BMP) entity beans congured as read-only
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.
EJB PerformanceTuning
Chapter 2 • TuningYour Application 35










