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

semantics. See “Value Added Features” in Sun GlassFish Enterprise Server 2.1 Developer’s Guide
for more details about the pass-by-reference ag.
To specify that an EJB component will use pass by reference semantics, use the following tag in
the sun-ejb-jar.xml deployment descriptor:
<pass-by-reference>true</pass-by-reference>.
This avoids copying arguments when the EJB component’s methods are invoked and avoids
copying results when methods return. However, problems will arise if the data is modied by
another source during the invocation.
Improving Performance of EJB Transactions
This section provides some tips to improve performance when using transactions.
Use Container-Managed Transactions
Container-managed transactions are preferred for consistency, and provide better
performance.
Don’t Encompass User Input Time
To avoid resources being held unnecessarily for long periods, a transaction should not
encompass user input or user think time.
Identify Non-Transactional Methods
Declare non-transactional methods of session EJB components with NotSupported or Never
transaction attributes. These attributes can be found in the ejb-jar.xml deployment descriptor
le. Transactions should span the minimum time possible since they lock database rows.
UseTX_REQUIRED for Long Transaction Chains
For very large transaction chains, use the transaction attribute TX_REQUIRED. To ensure EJB
methods in a call chain, use the same transaction.
Use Lowest Cost Database Locking
Use the lowest cost locking available from the database that is consistent with any transaction.
Commit the data after the transaction completes rather than after each method call.
Use XA-Capable Data Sources OnlyWhen Needed
When multiple database resources, connector resources or JMS resources are involved in one
transaction, a distributed or global transaction needs to be performed. This requires XA capable
resource managers and data sources. Use XA capable data sources, only when two or more data
EJB PerformanceTuning
Sun GlassFish Enterprise Server 2.1 Performance Tuning Guide • January 200938










