Execution resource allocation
You manage the allocation of the threads needed to execute a scenario suite using a resource allocation policy manager. On WebSphere® Application Server, the creation of the threads is delegated to work managers.
Each time an execution request is sent to the Scenario Service Provider (SSP) from Decision Center, the SSP has to decide the priority of the threads to use to run the scenario suite, and the maximum number of threads to allocate to a parallel execution of a simulation. On WebSphere Application Server, the priority of the threads is decided by which work manager to use.
The default scenario suite resource allocation policy manager has the following behavior:
Every thread created by the SSP has the same priority.
- If the SSP is deployed to WebSphere Application Server, the threads are all created in the NORMAL_PRIORITY_MANAGER work manager. The priority of the threads for this work manager is defined through the WebSphere Application Server Administration console. For more information, see Resource allocation on WebSphere Application Server.
- When the SSP is deployed to another application server, or run in Java™ SE, the threads are created with the priority Thread.NORM_PRIORITY. For more information, see Resource allocation on other application servers and Java SE.
Note:If you use the SSP on Linux, be aware that Java thread priorities all map to a single thread priority, 0 nice level. This means that regardless of the priority that you set for a thread, all threads execute with the same priority.
If your application server uses the Sun JVM, it is possible to set a priority explicitly by using the -XX:ThreadPriorityPolicy JVM argument. You must have root privileges to pass this argument successfully. For more information, refer to the JVM documentation.
The IBM® JVM, used by WebSphere Application Server, does not support the -XX:ThreadPriorityPolicy JVM argument.
The maximum number of threads you can allocate for a parallel execution of a simulation is defined by a parameter in the web.xml deployment descriptor of the SSP archive. The following parameter defines one thread for each scenario part in the simulation:
<init-param> <description>This parameter defines the maximum number of threads to allocate to one simulation if no custom scenario suite resource allocation policy manager is defined. A value of 0 or less means that the maximum number of threads that the SSP allocates is equal to the number of parts in the simulation. The value of this parameter is ignored if a custom scenario suite resources allocation policy manager is defined. </description> <param-name>MAX_NUMBER_OF_THREADS_PER_SIMULATION</param-name> <param-value>0</param-value> </init-param>In Decision Center, when the parts of the simulation are running in parallel, there is one runner instance per scenario suite part. Each runner executes the scenarios contained in the part. When reporting the number of scenarios for a simulation, the console displays the total number of scenarios.
Note:The number of scenarios for each part is only known to the runner when it is started. Therefore, if the runners are not started at the same time, because the thread pool or work manager cannot allocate enough resources for example, then the total number of scenarios reported is less than the total. When the waiting runners are started, the number of scenarios in the console is updated.
You can monitor the jobs running in the SSP if you login to the SSP web application using a Rule Execution Server role. For more information, see Checking the availability of Decision Validation Services.
Resource allocation on WebSphere Application Server
When the SSP is deployed to WebSphere Application Server, the creation of threads is delegated to work managers. For more information, see Work managers in the WebSphere Application Server documentation.
To dispatch an execution request to threads with different priorities, the SSP uses three different work managers. Each work manager defines its own thread priority, which is referenced in the web.xml deployment descriptor of the SSP web application. The priority of the scenario suite is then used to decide which work manager can run the scenario suite.
There are three initialization parameters defined for the SSP servlet:
- NORMAL_PRIORITY_MANAGER: defines the work manager to use to run normal priority threads.
- HIGH_PRIORITY_WORK_MANAGER: defines the work manager to use to run high priority threads.
- LOW_PRIORITY_MANAGER: defines the work manager to use to run low priority threads.
The three work managers are defined as follows in the deployment descriptor:
<init-param>
<description>Name of the high priority work manager to use to spawn high
priority threads in the SSP.
If this value is updated to use a dedicated work manager that
is not the default (wm/default), the resources references
section of this descriptor must be updated to make sure that
the new work manager is referenced in a resource-ref element.</description>
<param-name>HIGH_PRIORITY_WORK_MANAGER</param-name>
<param-value>wm/default</param-value>
</init-param>
<init-param>
<description>Name of the normal priority work manager to use to spawn
normal priority threads in the SSP.
If this value is updated to use a dedicated work manager that
is not the default (wm/default), the resources references
section of this descriptor must be updated to make sure that
the new work manager is referenced in a resource-ref element.</description>
<param-name>NORMAL_PRIORITY_WORK_MANAGER</param-name>
<param-value>wm/default</param-value>
</init-param>
<init-param>
<description>Name of the low priority work manager to use to spawn low
priority threads in the SSP.
If this value is updated to use a dedicated work manager that
is not the default (wm/default), the resources references
section of this descriptor must be updated to make sure that
the new work manager is referenced in a resource-ref element.</description>
<param-name>LOW_PRIORITY_WORK_MANAGER</param-name>
<param-value>wm/default</param-value>
</init-param>
The value for each parameter is the name of the work manager to use, as defined in the resource reference of the web.xml deployment descriptor under the <res-ref-name> element:
<resource-ref>
<res-ref-name>wm/default</res-ref-name>
<res-type>com.ibm.websphere.asynchbeans.WorkManager</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Unshareable</res-sharing-scope>
</resource-ref>
By default, all three work manager definitions reference the default work manager defined for a WebSphere Application Server instance (wm/default). All threads run with the same priority as defined by this work manager.
Using multiple work managers with different thread priorities assigned to them is only useful if you are defining a custom resources allocation policy manager. It is important to remember that the maximum number of threads that can be created by the SSP is defined by the work manager configuration. Work managers can be shared between different applications deployed on the same application server.
Resource allocation on other application servers and Java SE
On the other supported Java EE application servers and Java SE, a fixed thread pool size is used to run threads with different priorities. The size of the fixed thread pool is defined by the JRULES_JOBS_POOL_SIZE parameter in the web.xml deployment descriptor of the SSP web application.
The default value for the pool size is 10, as shown in the following example:
<init-param>
<description>The number of threads in the pool for asynchronous
executions (jobs)</description>
<param-name>JRULES_JOBS_POOL_SIZE</param-name>
<param-value>10</param-value>
</init-param>
In Java SE, you need to use an IlrLocalSSPService constructor that takes the pool size as an argument.
The priority of the thread is defined by the resource allocation policy manager. There are three priority values:
- Thread.NORM_PRIORITY for priority NORMAL
- Thread.MAX_PIORITY for priority HIGH
- Thread.MIN_PRIORITY for priority LOW
When a thread is started, it is queued according to its priority. When all threads in the pool are running, new thread requests are queued until a thread from the pool completes an execution. Threads waiting to be executed are prioritized, which means if a HIGH priority scenario suite is added to the queue, it is added closer to the front of the queue compared to all the other scenario suites that have a lower priority.