How to reduce the number of threads created by Fuse ESB 7 during startup?

Solution Verified - Updated -

Environment

Fuse ESB 7

Issue

How to use the "felix.threading.disable" and the "felix.threading.timeout" configuration properties?

Resolution

From Fuse ESB 7.0.1 onwards it is possible to reduce the number threads created at startup, by using the following configuration variables:


- felix.threading.disable - if set to true, bypass thread creation during OSGi bundle startup (same as Fuse ESB 4.4.1 behavior) - felix.threading.timeout - the number of seconds the thread will stay alive after the OSGi bundle has been started. If set to 0, threads will die immediately after bundle is started

Both properties can be set in etc/config.properties or etc/custom.properties.

Root Cause

In Fuse ESB 7, a thread pool is created for each bundle. By default these threads will remain active in an idle state for a maximin of 60 seconds.

The following snippet from a thread dump taken shortly after Fuse ESB 7 has started, shows the naming convention of the threads:


Thread [pool-org.apache.servicemix.bundles.jsch-0.1.44.2-thread-1] (Running) Thread [pool-org.fusesource.fabric.fabric-boot-commands-7.0.0.fuse-061-thread-1] (Running) Thread [pool-org.apache.camel.karaf.camel-karaf-commands-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.camel.camel-core-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.camel.camel-spring-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.camel.camel-jms-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.activemq.activemq-camel-5.5.1.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.camel.camel-bindy-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.camel.camel-csv-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.camel.camel-cxf-transport-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.commons.net-2.2.0-thread-1] (Running) Thread [pool-org.apache.servicemix.bundles.commons-csv-1.0.0.r706899_3-thread-1] (Running) Thread [pool-org.apache.camel.camel-exec-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.commons.exec-1.0.1-thread-1] (Running) Thread [pool-org.apache.camel.camel-jdbc-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.camel.camel-cxf-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.camel.camel-ftp-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.camel.camel-jasypt-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.commons.io-1.4.0-thread-1] (Running) Thread [pool-org.apache.camel.camel-blueprint-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.camel.camel-saxon-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.servicemix.bundles.saxon-9.1.0.8_2-thread-1] (Running) Thread [pool-org.apache.camel.camel-snmp-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.servicemix.bundles.snmp4j-1.8.1.5-thread-1] (Running) Thread [pool-org.apache.camel.camel-ognl-2.9.0.fuse-7-061-thread-1] (Running) Thread [pool-org.apache.servicemix.bundles.javassist-3.12.1.GA_2-thread-1] (Running) Thread [pool-org.apache.servicemix.bundles.ognl-3.0.2.1-thread-1] (Running) Thread [pool-org.apache.camel.camel-routebox-2.9.0.fuse-7-061-thread-1] (Running)

Why has this behavior changed since the previous version (Fuse ESB 4.4.1)?
As each bundle is now associated with a thread group, the thread(s) spawned by a given bundle can be easily associated back to that bundle. This can be used to diagnose which bundles are not stopping threads correctly and is very useful when used the newly added "dev:threads" command.

Depending on the number of bundles deployed, this change can result in a large number of threads created during Fuse ESB 7 startup (approx one thread per bundle) but each thread should only live for a short period of time - a maximin of 60 seconds when it has reached an idle state.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments