Uploaded image for project: 'WildFly Core'
  1. WildFly Core
  2. WFCORE-1934

Make number of thread size for ServerService Thread Pool configurable

XMLWordPrintable

    • Hide

      I attached two reproducible applications which have a possibility to spawn many ServerService Thread Pool threads:

      • ServerServiceThreadPool_persistence_unit.zip
      • ServerServiceThreadPool_ejb_startup_singleton.zip

      0. Extract ServerServiceThreadPool_persistence_unit.zip

      1. Execute the attached script, generate-persistence-jar.sh. This generates META-INF/persistence.xml which contains the specified number of <persistence-unit> and a jar file which contains it:

      $ ./generate-persistence-jar.sh <number-of-persistence-unit> <jar-file-name>
      

      For example:

      $ ./generate-persistence-jar.sh 2000 test.jar
      

      2. Deploy the generated jar file (test.jar) to WildFly

      3. You will see many ServerService Thread Pool threads are running when starting WfildFly or during application deployment

      0. Extract ServerServiceThreadPool_ejb_startup_singleton.zip

      1. Execute the attached script, generate_ejb_startup_singleton.sh. This generates the specified number of @Startup @Singleton EJB java source files :

      $ ./generate_ejb_startup_singleton.sh generate <number>
      

      For example:

      $ ./generate_ejb_startup_singleton.sh generate 2000
      

      2. Build and deploy jboss-helloworld-singleton.war to WildFly

      $ cd helloworld-singleton/
      $ mvn clean package wildfly:deploy
      

      3. You will see many ServerService Thread Pool threads are running when starting WfildFly or during application deployment

      Show
      I attached two reproducible applications which have a possibility to spawn many ServerService Thread Pool threads: ServerServiceThreadPool_persistence_unit.zip ServerServiceThreadPool_ejb_startup_singleton.zip 0. Extract ServerServiceThreadPool_persistence_unit.zip 1. Execute the attached script, generate-persistence-jar.sh . This generates META-INF/persistence.xml which contains the specified number of <persistence-unit> and a jar file which contains it: $ ./generate-persistence-jar.sh <number-of-persistence-unit> <jar-file-name> For example: $ ./generate-persistence-jar.sh 2000 test.jar 2. Deploy the generated jar file (test.jar) to WildFly 3. You will see many ServerService Thread Pool threads are running when starting WfildFly or during application deployment — 0. Extract ServerServiceThreadPool_ejb_startup_singleton.zip 1. Execute the attached script, generate_ejb_startup_singleton.sh . This generates the specified number of @Startup @Singleton EJB java source files : $ ./generate_ejb_startup_singleton.sh generate <number> For example: $ ./generate_ejb_startup_singleton.sh generate 2000 2. Build and deploy jboss-helloworld-singleton.war to WildFly $ cd helloworld-singleton/ $ mvn clean package wildfly:deploy 3. You will see many ServerService Thread Pool threads are running when starting WfildFly or during application deployment

      Provide a way to configure maximumPoolSize of ServerService Thread Pool. It defaults to Integer.MAX_VALUE and it's unable to be changed in the current implementation:

      https://github.com/wildfly/wildfly-core/blob/master/server/src/main/java/org/jboss/as/server/ServerService.java#L446-L449

      446         public synchronized void start(StartContext context) throws StartException {
      447             executorService = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 20L, TimeUnit.SECONDS,
      448                     new SynchronousQueue<Runnable>(), threadFactory);
      449         }
      

      Though the threads will disappear after 20 seconds of finishing a task, ulimit (nproc, max user processes) has a possibility to run out and "java.lang.OutOfMemoryError: unable to create new native thread" would occur depending on deployed applications. For example, an application coming with many <persistence-unit> entries in persistence.xml or a lot of @Startup @Singleton EJB can cause spawning a lot of ServerService Thread Pool thread.

      Even if ulimit can be configurable and it is recommended to be tuned in a production environment, making maximumPoolSize of ServerService Thread Pool configurable would be helpful.

            yborgess1@redhat.com Yeray Borges Santana
            rhn-support-mmiura Masafumi Miura
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: