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

EJB Container Settings
The EJB Container has many settings that aect performance. As with other areas, use monitor
the EJB Container to track its execution and performance.
Monitoring the EJB Container
Monitoring the EJB container is disabled by default. Enable monitoring with the Admin
Console under Congurations > cong-name > Monitoring. Set the monitoring level to LOW
for to monitor all deployed EJB components, EJB pools, and EJB caches. Set the monitoring
level to HIGH to also monitor EJB business methods.
Tuning the EJB Container
The EJB container caches and pools EJB components for better performance. Tuning the cache
and pool properties can provide signicant performance benets to the EJB container. Set EJB
cache and pool settings in the Admin Console Congurations > cong-name > EJB Container
(EJB Settings).
The pool settings are valid for stateless session and entity beans while the cache settings are
valid for stateful session and entity beans.
Overview of EJB Pooling and Caching
Both stateless session beans and entity beans can be pooled to improve server performance. In
addition, both stateful session beans and entity beans can be cached to improve performance.
TABLE 3–1 Bean Type Pooling or Caching
Bean Type Pooled Cached
Stateless Session Yes No
Stateful Session No Yes
Entity Yes Yes
The dierence between a pooled bean and a cached bean is that pooled beans are all equivalent
and indistinguishable from one another. Cached beans, on the contrary, contain conversational
state in the case of stateful session beans, and are associated with a primary key in the case of
entity beans. Entity beans are removed from the pool and added to the cache on ejbActivate()
and removed from the cache and added to the pool on ejbPassivate(). ejbActivate() is
called by the container when a needed entity bean is not in the cache. ejbPassivate() is called
by the container when the cache grows beyond its congured limits.
EJB Container Settings
Chapter 3 • Tuning the Enterprise Server 53










