Thursday, September 07, 2006

Common Performance Tuning Practices for EJBs

  1. Use Local interfaces that are available in EJB2.0 if you deploy both EJB Client and EJB in the same EJB Server.

  2. Use Vendor specific pass-by-reference implementation to make EJB1.1 remote EJBs as Local EJBs if you deploy both EJB Client and EJB in the same EJB Server.

  3. Wrap entity beans with session beans to reduce network calls and to promote declarative transactions. Optionally, make entity beans as local beans where appropriate.

  4. Make coarse grained session and entity beans to reduce network calls.

  5. Control serialization by modifying unnecessary data variables with  'transient' key word to avoid unnecessary data transfer over network.

  6. Cache EJBHome references to avoid JNDI lookup overhead.

  7. Avoid transaction overhead for non-transactional methods of session beans by declaring 'NotSupported' or 'Never' transaction attributes that avoid further propagation of transactions.

  8. Set proper transaction age(time-out) to avoid large transaction.

  9. Use clustering for scalability.

  10. Tune thread count for EJB Server to increase EJB Server capacity.

  11. Choose servlet's HttpSession object rather than Stateful session bean to maintain client state if you don't require component architecture and services of Stateful session bean.

  12. Choose best EJB Server by testing with ECperf tool kit.

  13. Choose normal java object over EJB if you don't want built-in services such as RMI/IIOP, transactions, security, persistence, resource pooling, thread safe, client state etc..

Stateless session beans

  1. Tune the Stateless session beans pool size to avoid overhead of creation and destruction of beans.

  2. Use setSessionContext() or ejbCreate() method to cache bean specific resources.

  3. Release acquired resources in ejbRemove() method

Stateful session beans

  1. Tune Stateful session beans cache size to avoid overhead of activation and passivation process.

  2. Set optimal Stateful session bean age(time-out) to avoid resource congestion.

  3. Use 'transient' key word for unnecessary variables of Stateful session bean to avoid serialization overhead.

  4. Remove Stateful session beans explicitly from client using remove() method.

Entity beans

  1. Tune the entity beans pool size to avoid overhead of creation and destruction of beans.

  2. Tune the entity beans cache size to avoid overhead of activation, passivation and database calls.

  3. Use setEntityContext() method to cache bean specific resources.

  4. Release acquired resources in unSetEntityContext() method

  5. Use Lazy loading to avoid unnecessary pre-loading of child data.

  6. Choose optimal transaction isolation level to avoid blocking of other transactional clients.

  7. Use proper locking strategy.

  8. Make read-only entity beans for read only operations.

  9. Use dirty flag to avoid unchanged buffer data updation.

  10. Commit the data after the transaction completes to reduce database calls in between transaction.

  11. Do bulk updates to reduce database calls.

  12. Use CMP rather than BMP to utilize built-in performance optimization facilities of CMP.

  13. Use ejbHome() methods for global operations.

  14. Tune connection pool size to reduce overhead of creation and destruction of database connections.

  15. Use JDBC tuning techniques in BMP.

  16. Use direct JDBC rather than using entity beans when dealing with huge data such as searching a large database.

  17. Use business logic that is specific to entity bean data.

Message driven beans

  1. Tune the Message driven beans pool size to promote concurrent processing of messages.

  2. Use setMesssageDrivenContext() or ejbCreate() method to cache bean specific resources.

  3. Release acquired resources in ejbRemove() method.

  4. Use JMS tuning techniques in Message driven beans.

Get more information

Tags: performance tuning, ejbs, ejb client, ejb server, persistance, setsessioncontext, session beans, entity beans, mdb, ejbhome

Can't find what you're looking for? Try Google Search!
Google
 
Web eshwar123.blogspot.com

Comments on "Common Performance Tuning Practices for EJBs"