
EJB Performance Tuning
semantics. See “Value Added Features” in Sun GlassFish Enterprise Server 2.1 Developer’s Guide for more details about the
To specify that an EJB component will use pass by reference semantics, use the following tag in the
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 modified 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
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
Use TX_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 Only When 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
38 | Sun GlassFish Enterprise Server 2.1 Performance Tuning Guide • January 2009 |