We help IT Professionals succeed at work.

EJB Performance issue

kmapper asked

I have a XML file containing about 20K person names.
For each person I need to perform some update in my DB.
Then, when if the entire process completed successfully, I need to change a perform a final update in the DB. (I set a status - successfull)

The problem:
If I try to do all the process (20k persons) in a single transaction, I get a timeout exception.
So I splitted the TX in many small TX. One Tx per person.
Now, calling 20k EJB in a loop cause my application to slow down dramatically!!

Some guy told me to use a msg driven bean, but I dont see how this will solve my problem. Since I need to keep a trace of whats going on in my entire process in order to set the status (suddess/fail).

Someone have an idea?  
Watch Question

Dejan PažinHead of SW Development


Calling them in a loop is certainly no good.

You can increase the timeout value. It wont speed up the process, but the client will wait for the reposnse, it wont throw the timeout exception.
Top Expert 2004

You can set a buffer limit. Say parse 1000 persons from the XML file and make an EJB call for 1000 update. After it is completed, proceed with the second call. 1000 is just a number. You can choose a buffer size depending on your app server/ db/application performance.


Well, ok, but how do I deciede wether 1000 is correct or not. If the server slows down, maybe this number would need to be 100..
If I decide to process 100 persons at every call, then I still make 250 EJB call which is too much...

I'm starting to think about bypassing the persistence framework and go against the DB via JDBC, how does it sound to you guys?

Top Expert 2004
That certainly is a great approach. If your EJB does not have any complex business logic and if all that you are doing is updating several rows you can even consider using PLSql.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.