[OJB-developers] [long] OJB+JBoss Performance and Problems
Brought to you by:
thma
From: hafman <ha...@we...> - 2002-03-06 18:48:38
|
Hi all, we would like to use OJB as persistence layer and to generate views for clients, managed by session beans in JBoss. We do some tests to compare performance of OJB with other persistence layers against HSQL. We also testing a multithreaded testcase and a rollback testcase. When running the rollback testcade we encountered a couple of problems, see below. OJB version 0.7344 (CVS) ################### Performance Insert/Delete ################## 1. SessionBean facade using OJB as persistence layer (3-tier) with declarative transaction. hsql in server mode in same vm as jboss. 2. SessionBean facade using local EntityBeans as persistence layer (3-tier) with declarative transaction. hsql in server mode in same vm as jboss. 3. Using Torque (http://jakarta.apache.org/turbine/torque/index.html), part of the Turbine project as persistence layer (2-tier). Turbine run in standalone modus, hsql in server mode in DIFFERENT vm as jboss. The test client store and remove 1000 value objects: a. One remote call per object to store b. List of all objects send to server to store (one remote connection to store) c. One remote call per object to delete d. List of all objects send to server to remove (one remote connection to ´remove) store delete Scenario (ms)| a. | b. | c. | d. | ----------------------------------------- 1.SB+OJB | 3585| 763 | 3112| 466| 2.SB+loc. EB | 4848| 2516| 3421| 1710| 3.turbine | -- |(1081)| -- |(956)| OJB does an excellent job! Performance compared with local entiy beans as persistence layer is better by far: ~27% faster to store one object per remote call ~60% faster to store 1000 objects per remote call Even more remarkable OJB is a bit faster then the persistence layer Torque. (Note: Using Torque run in different vm) Excellent performance!! ######################################################### ##################### Multithreaded Test #################### In the multithreaded testcase running 10 clients and every client do 100 store and delete operations. One store/delete operation per remote call 1.SB+OJB 7503 2.SB+loc. EB 9281 Using OJB as persistence layer runs ~ 20% faster ######################################################## ##################### Rollback Test ######################## In the rollback testcase we send a list of objects to store to the server. After storing the objects a hard coded exception is fired before leaving method. We encountered a problem: Every call to a session bean method starts a container managed transaction (using declarative transaction with transaction attribute required). In our testmethod we want to simulate first storing data objects and calling futher (e.g. sending an email) functionality. If something goes wrong after successfully storing the data, we want rollback the complete transaction. And this did not work out of the box, cause the PB commits the database transaction (no rollback possible). public void performException(List offerings) { store(offerings); throw new UnexpectedError("Performed test exception"); } We use our own implementation of PersistenceBroker, which implements javax.transaction.Synchronization. This allows us to defer the committing of the database transaction, after successfully committing the container transaction. The session bean registers each instance of PB with the current transaction (see below) Has anybody a different (better :-)) solution for this problem? public class OJBSessionBean extends CALSessionBean { protected TransactionManager tm; ..... /** * Here we lookup for ojbRepository file and the TransactionManager */ public void ejbCreate() { super.ejbCreate(); ..... tm = (TransactionManager) Creator.lookup("java:/TransactionManager"); } /** * Use this method to get a new PersistenceBroker instance. */ public PersistenceBroker getBroker() { try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(ojbRepository); /* associate PB with transaction of the container and begin transaction on the connection hold by PB or, if we had no transaction, only return the broker */ if (registerSynchronization(broker)) { if (log.isDebugEnabled()) log.debug("Automatic call PB.beginTransaction()"); broker.beginTransaction(); } return broker; } catch (Exception e{throw new UnexpectedError(e);} } /** * Returns true, if the current thread is associated with a transaction. */ private boolean registerSynchronization(PersistenceBroker broker) { boolean hasActiveTransaction = false; try { Transaction ta = tm.getTransaction(); if (ta != null) { ta.registerSynchronization((CALPersistenceBroker)broker); hasActiveTransaction = true; } } catch (Exception e){log.error("Register PersistenceBroker failed", e); return hasActiveTransaction; } } ######################################################## Thanks in advance Armin |