performance - EJB transactions slowing down in one thread -
i have performance problem process. it's asynchronous task launched in cmt bean (on jboss server).
1 iteration performs 1 update , 3 inserts db via hibernate. process divided new transactions every 100 iterations.
flush called on entitymanager after every update/insert.
while starting performance of first batch satisfying (around 5-8s) slows down drastically time. 30th batch takes around 30s finish , later grows on 2 minutes per batch.
i tried switching flushmodetype commit, manual clearing/closing entitymanagers, clearing entitymanagers cache, looked memory leaks , can't find reason slow down.
i measured little bits of code execution time , every code involving database connection slows down time. understand transaction slows more entities processed why new transaction slower?
the latest process consists of 250 000 iterations (2500 transactions in 1 thread) , takes forever end.
if needed i'll provide more information. appreciated.
i tried simplifying code 1 hibernate insert , no other operations , still slows time. abstract pseudo view of what's going on inside.
bean1 @asynchronous @transactionattribute(transactionattributetype.requires_new) public void maintask(){ while(...){ subtask(); } } bean2 @transactionattribute(transactionattributetype.requires_new) public void subtask(){ 100.times{ 3*insert 1*update } }
i sure suggestions might not accurate 1 or tried them already, i'd give try. mentioned db connection bottleneck, i'll go after that.
after reading question, find time taken transaction proportional iteration number. looks entities created in first iteration being sent hibernate in next iteration.
for example, in 4th iteration, entities created in 1st,2nd , 3rd iterations being sent update or being sent hibernate somehow.
that reason degradation of performance iteration progresses. number of records updated/inserted/selected increases each iteration.
i can think of following possibilities on top of head -
hibernate session used in first iteration being used till end. due this, entities created in first iteration being updated in later iterations well. read tried closing entity managers etc. still, please check place sesssion ending. can create new session in each transaction or delete entities created in session after each transaction.
the list filters records each iteration sending processed records. means list should send records 300 399 in 3rd iteration, records 0 399 sent transaction.
if you're using hql, try using named query. last time when used hibernate (about 8 months back), noticed when hql used number of objects loaded hibernate more named query.
hibernate provides way print actual sql query/parameters sent db. can check actual query sent db. link - how print query string parameter values when using hibernate
Comments
Post a Comment