Announcement Announcement Module
No announcement yet.
Trasactions and Performance Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trasactions and Performance

    Our Project requires a bulk upload of data into the database on a trasactional basis. We are using Spring's TransactionProxyFactoryBean to provide declarative transactions in our method. I was doing a load test and found that trying to create about 10000 records in a transaction is taking about 1 hour. If i take the loop out of the method and call it outside of the service layer, the same process takes about 15 minutes.

    Can anybody help me understand why this is happening? My CPU is at 100% when i run the bulk upload.

    Here is my application-context code for the service in question

    <bean id="tradingPartnerService"
    class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager" ref="transactionManager" />
    <property name="preInterceptors">
    <ref local="serviceInterceptor" />
    <property name="target">
    class="com.ebizformedia.service.impl.TradingPartne rServiceImpl">
    <property name="tradingPartnerDao">
    <ref bean="TradingPartnerDao" />
    <property name="targetTradingPartnerDao">
    <ref bean="TargetTradingPartnerDao" />
    <property name="aliasDao">
    <ref bean="AliasDao" />
    <property name="searchDao">
    <ref bean="SearchDao" />
    <property name="gatewayRoutingDao">
    <ref bean="GatewayRoutingDao" />
    <property name="commonUtilsService">
    <ref bean="commonUtilsService" />
    <property name="entityAccessService">
    <ref bean="entityAccessService" />
    <property name="contactService">
    <ref bean="contactService" />
    <property name="mediaTypeService">
    <ref bean="mediaTypeService" />
    <property name="proxyTargetClass" value="true" />
    <property name="transactionAttributes">
    <prop key="*">PROPAGATION_REQUIRED</prop>


  • #2
    Any Ideas? I look at the memory usage.. when i loop inside the transaction. It takes up about 80% of the memory and CPU is 100%. If i take out the loop from inside the transaction boundary and loop in my Junit and individually call the method in the service bounded by transaction, memory usage is minimal as well as CPU.

    I am out of ideas as to why this is happening.. How does it matter if the objects are created inside a transaction or outside? Why is my CPU/Memory Usage so high?

    Desperate for an answer..


    • #3
      I found out the issue..

      It has nothing to do with Spring transactions. My bad. I was not doing a flush and a clear on the hibernate session for each insert. That was the problem.

      Flush and Clear will cut the persistent object link with the database thereby allowing the object to be garbage collected. Otherwise the object is stored in the second level cache and never gets released..That was the reason for the memory issues and slow performance..