6 Replies Latest reply on Apr 19, 2011 9:58 AM by jaikiran pai

    Maximum concurrent calls of an Asynchronous method in a SLSB

    ilker ulutas Newbie

      Recently I've been struggling with a problem causing a bottleneck in my application which I encountered during load testing. Then I pinpointed the issue and wrote a simple version of it to discuss.

       

      (I'm using JBossAS 6.0.0.Final)

       

      First we have a SLSB with an asyncronous method called "sleep":


      ----------------------- SleeperAgent.java ---------------------

      import javax.ejb.Asynchronous;

      import javax.ejb.Stateless;

      import org.apache.log4j.Logger;

       

      @Stateless

      public class SleeperAgent {

       

      Logger logger = Logger.getLogger(getClass());

       

      @Asynchronous

      public void sleep(int count){


                          logger.info(count + " Going to sleep");

                          try {

                                    Thread.sleep(15000);

                          } catch (InterruptedException e) {

                                    e.printStackTrace();

                          }

                }

      }

      --------------------------------------------------------------------------------

       

      Then we call that asynch method from JMX console for testing purposes:

       

      ------------------------------- TestService.java -------------------------------------------------

      @Service(objectName = "Development:service=Tests", name = "Tests")

      public class TestService implements TestServiceManagement{

       

      @EJB private SleeperAgent sleeper;


                public void quickTest(){

                          for(int i=0;i<30;i++){

                                    sleeper.sleep(i);

        }

                }

      }

      ----------------------------------------------------------------------------------------------------------

       

      When the quickTest method is run, sleep method gets hang of 10 threads for 15 seconds and 10 instances SleeperAgent SLSB are created. Then the quick test method returns before the rest asynch method calls are performed. The rest of the threads (next 20) are ready but can't proceed until 15 seconds pass. Then they can continue.

       

      First I thought this was related with the max thread limit defined in the thread-pool-jboss-beans.xml under deploy folder which the original should be as follows:

            <bounded-queue-thread-pool-executor name="ThreadPool" blocking="true">

               <thread-factory name="ShortTasksThreadFactory"/>

               <queue-length count="500" per-cpu="200"/>

               <core-threads count="5" per-cpu="2"/>

               <max-threads count="10" per-cpu="3"/>

               <keepalive-time time="30" unit="seconds"/>

               <task-filter>

                  <clear-context-classloader/>

                  <clear-tls/>

               </task-filter>

            </bounded-queue-thread-pool-executor>

       

      I increased max-threads count to 30 and per-cpu to 5 but nothing seemed to change.

       

      Then I tried increasing the default strictmaxpool setting in ejb3-interceptors-aop.xml file but that didn't have much effect either:

            <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Pool)">

               @org.jboss.ejb3.annotation.Pool (value="StrictMaxPool", maxSize=50, timeout=10000)

            </annotation>

      Also defining @Pool annotation with value="StrictMaxPool" or value="ThreadLocal" explicity for SleeperAgent class was of no use.

       

      I can't seem to find the source which is limiting 10 concurrent calls. Do you know is it possible to increase this value somehow? Thanks for your help.

       

      -iLKeR-