Skip to main content
Summary How to configure thread pools in Artix JAX-RPC/C ?
Article Number 12968
Environment Artix C Runtime Artix JAX-RPC Runtime All Supported Operating Systems
Question/Problem Description How to configure thread pools in Artix JAX-RPC/C ?
What are the different settings to configure thread pools in Artx JAX-RPC/C ?
What are the different thread pool configuration defaults in Artix JAX-RPC/C ?
How can I configure an Artix JAX-RPC/C service to have its own pool of threads?
Can more than one Artix bus exist within the same Artix JAX-RPC/C process?
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution

Before describing how to configure the different threading settings in Artix JAX-RPC/C , keep in mind the following facts that take place when the static init() method is called on the Artix Bus class:

 

  • If init() has not been already called, it will return a new Bus object.
  • If init() has already been called using the same arguments, it will return the existing Bus object.
  • If init() has already been called using different "-ORBname" and "-ORBid" arguments, it will return a new Bus object; effectively allowing for multiple instances of the Bus to exist within the same process.

 

Please take a look at a hierarchical representation of the objects to be configured and how they fit together. Note that this representation applies to each individual instance of the Artix Bus; thus, if multiple instances of the Bus exist within the same process, each Bus instance will have its own hierarchy of workqueues.

ORB -> ORB's workqueue
|
->1..1  Artix Bus -> Bus' workqueue
        |
        ->0..n  Artix Service(s)
[-> optional Service's workqueue, possibly shared with other Services]
                |
                ->0..m  Artix Port(s)
                        |
                        ->1..1  Artix Server Transport instance

A workqueue is a queue of executable work items, coupled with a thread pool. A workqueue has 5 parameters to configure:

 initial_threads
 low_water_mark
 high_water_mark
 stack_size   ( in bytes)
 max_queue_size

These 5 parameters are going to be present, although with different prefixes, for all the workqueues to be covered. These parameters should be configured when resource consumption becomes a concern (typically during load peak times); in particular, maximum number of threads to be created, stack memory to be allocated and maximum number of request to be queued up for processing. For specific details on what each of these configuration settings do, please refer to the Artix Configuration Reference guide.

1. ORB's workqueue.

There's an ORB instance for every Artix Bus instance. An ORB always creates one workqueue for itself  and, as explained above, this workqueue has 5 configurable parameters:

 

 thread_pool:initial_threads
 thread_pool:low_water_mark
 thread_pool:high_water_mark
 thread_pool:max_queue_size
 thread_pool:stack_size

The default values for each of these variables are: "5", "-1", "-1", "-1", respectively. ("-1" stands for "unlimited").
For the last variable, the default is OS dependant. 0 for most operating systems (i.e. it defaults to whatever pthread_create()/CreateThread() decides. 128K for HP-UX PA-RISC, 1MB for HP-UX IA64). In a typical Artix installation, this variable is already set in the out-of-the box configuration file ($IT_PRODUCT_DIR/cxx_java/etc/domains/artix.cfg) to "1048576"; effectively making the default 1MB on all platforms.

2. Artix Bus' workqueue.

An Artix Bus always creates one workqueue for itself. This workqueue also has 5 configurable parameters:

 bus:thread_pool:initial_threads
 bus:thread_pool:low_water_mark
 bus:thread_pool:high_water_mark
 bus:thread_pool:stack_size
 bus:thread_pool:max_queue_size

The default values for each of these variables are: "5", "-1", "-1", "1048576", "-1", respectively. ("-1" stands for "unlimited").
If any of these variables are not specified, configuration lookup falls back to the ORB's workqueue variables. For example, the variable "thread_pool:stack_size" set in $IT_PRODUCT_DIR/cxx_java/etc/domains/artix.cfg affects both, the Bus' and the ORB's workqueues.

3. Artix Service's workqueues.

The relationship between Services and workqueues can be categorized in three different ways:

3.1 A service can use the Bus's workqueue.

This is the default; however, the out-of-the-box configuration file $IT_PRODUCT_DIR/cxx_java/etc/domains/artix.cfg overrides it by setting the global variable
"service:owns_workqueue" to "true", making option 3.2 the effective default. Although, you can change this by either commenting the variable out or by setting it to "false".

3.2 A service can create its own workqueue.

This option is turned on by either one of the following two configuration variables:

 service:SERVICE-QNAME:owns_workqueue = "true";    // specific for the service SERVICE-QNAME (namespace:local_part).
 service:owns_workqueue = "true";                                // affects all services in a Bus

As mentioned above in 3.1, the "service:owns_workqueue" variable is by default set to "true" in the out-of-the-box configuration file.

The parameters of the workqueue created by the service can be controlled with:

 service:<SERVICE-QNAME>:thread_pool:initial_threads
 service:<SERVICE-QNAME>:thread_pool:low_water_mark
 service:<SERVICE-QNAME>:thread_pool:high_water_mark
 service:<SERVICE-QNAME>:thread_pool:stack_size
 service:<SERVICE-QNAME>:thread_pool:max_queue_size

The default values for each of these variables are: "1", "5", "25", "1048576", "-1", respectively. ("-1" stands for "unlimited").
If any of these variab./BLOCKQUOTE>

The default values for each of these variables are: "5", "-1", "-1", "-1", respectively. ("-1" stands for "unlimited").
For the last variable, the default is OS dependant. 0 for most operating systems (i.e. it defaults to whatever pthread_create()/CreateThread() decides. 128K for HP-UX PA-RISC, 1MB for HP-UX IA64). In a typical Artix installation, this variable is already set in the out-of-the box configuration file ($IT_PRODUCT_DIR/cxx_java/etc/domains/artix.cfg) to "1048576"; effectively making the default 1MB on all platforms.

3.3 Set of Services can share a named workqueue, created by the Bus specifically for them

This option is turned on by configuring either of the following:

 service:<SERVICE-QNAME>:shares_workqueue = "<WORKQUEUE_NAME>"; // for individual services
 service:shares_workqueue = "<WORKQUEUE_NAME>";                                   // for all services in a Bus

A shared named worqueue is configured with

 service:<WORKQUEUE_NAME>:thread_pool:initial_threads
 service:<WORKQUEUE_NAME>:thread_pool:low_water_mark
 service:<WORKQUEUE_NAME>:thread_pool:high_water_mark
 service:<WORKQUEUE_NAME>:thread_pool:stack_size
 service:<WORKQUEUE_NAME>:thread_pool:max_queue_size

The default values for each of these variables are: "5", "-1", "-1", "1048576", "-1", respectively. ("-1" stands for "unlimited").
If any of these variables is not set, configuration look-up falls back exactly as described in 3.2

 

4. Considerations for Artix transports

 

Artix HTTP and HTTPS transports will use some threads borrowed from the bus' thread pool in order to perform transport related operations; by default, each of them will borrow 5 threads from the pool. This means that if you are using HTTP and HTTPS transports in the same Artix instance you will need to account for 10 threads to be taken from the bus' thread pool on behalf of those transports and these threads will not be available to process regular work items. Consequently, you need to make sure the ORB's and the bus' thread pools are configured to be large enough to accommodate for this.

 

The number of threads that is borrowed for each transport can also be configured via the following two variables:

 

plugins:https:pool:max_threads
plugins:http:pool:max_threads

The default value for each of these variables is: "5"

5. Configuration considerations when multiple Artix buses are created within the same process

When multiple Artix buses exist in the same process, you can configure each bus independently by ensuring that each bus gets its configuration from a unique configuration scope. This configuration scope is provided to each bus via the "-ORBname" argument passed to init() during initialization. For instance, if two Artix buses have been created and two different "-ORBname" parameters have been provided ("bus_1" and "bus_2"), you will need to add each bus' thread.ing settings under each corresponding configuration scope as shown below:


bus_1 {

   thread_pool: ...
   ...
  
};

bus_2 {

   thread_pool: ...
   ...

};


 

.
Workaround
Notes
Attachment
Created date: 06 September 2011
Last Modified: 13 February 2013
Last Published: 23 June 2012
First Published date: 09 September 2011

#KnowledgeDocs
#Orbix