In BRIX, the worker service is responsible for the validation, compilation, and execution of server scripts. To improve its performance, you can allocate dedicated execution pools:
- For system structures where scripts are initiated. For example, for widget scripts or a specific business process.
- For specific types of script processing requests. For example, for their compilation or execution.
начало внимание
The configuration of dedicated worker pools is available for BRIX On‑Premises Enterprise starting from version 2025.6.
конец внимание
This article describes how the system:
Script processing algorithm in the worker service
The following tools are used to distribute the load on the worker service:
- Kubernetes. Ensures the scaling of service replicas where scripts are executed.
- RabbitMQ. Acts as a router, distributing script execution requests among available worker replicas.
With the default worker configuration, script processing requests are sent to RabbitMQ and distributed within a shared queue. This increases the load on the service and slows down script execution.
Configuring dedicated pools for specific types of scripts helps optimize this load distribution. After such configuration:
- In Kubernetes, data is transmitted to deploy the pools.
- In RabbitMQ, a separate queue is automatically added for each configured pool.
Let’s take a closer look at how script request routing works:
- Routing key determination.
When a script is launched, a request containing its parameters is automatically generated: company name, script compilation or execution, the system structure from which the script was initiated, etc. Based on this data, a routing key is determined:
- If you have configured dedicated pools for specific scripts, the request gets a key equal to the worker pool identifier.
- If no suitable pool exists, the
default
key is assigned.
- Request distribution.
Requests with assigned keys are sent to RabbitMQ, where they are routed:
- If you have specified dedicated worker pools for certain scripts, RabbitMQ automatically creates queues for these pools. Requests are distributed to these queues based on the assigned key.
- Requests with the
default
key are placed in the sharedscript.default
queue.
- Request processing.
Requests are distributed from the queues to worker replicas:
- From dedicated queues, script processing requests are sent to the configured worker pools.
- From the
script.default
queue, requests are distributed among shared worker replicas.
Configure worker pools
The configuration of worker pools consists of two steps:
Step 1: Define the worker pool configuration
To create a dedicated worker pool for specific scripts, specify its configuration in the values-elma365.yaml
file. Define the script selection criteria, autoscaling parameters for pool replicas, and script execution timeout settings.
To do this:
- Create a backup of the
values-elma365.yaml
file filled during BRIX installation. This is necessary before editing, as incorrect parameter settings may cause BRIX application failures. - In the
values-elma365.yaml
configuration file, go to theglobal
block and fill in the parameters in theworkerPoolCfg
section.
начало примечание
Example of parameter configuration in the workerPoolCfg section
global:
workerPoolCfg:
pools:
namespacepool: # The pool name is specified in free form using lowercase Latin letters and numbers, up to 20 characters long
sources: # Filters for selecting scripts to be distributed to the pool
- company: head
operation: execute
type: process
namespace: crm
code: createlead
autoscaling: # Autoscaling parameters for the pool
enabled: true
type: "hpa"
minReplicas: 1
maxReplicas: 9
options: # Additional pool options — timeouts
defaultScriptTimeoutSeconds: 180
maxScriptTimeoutSeconds: 1200
конец примечание
For this, specify:
- Pool identifier (
pools
). The name of the worker pool. Assign a custom name to the pool using lowercase Latin letters and numbers, up to 20 characters long. - Sources of script processing requests (
sources
).
When a script is launched in the system, a request for its processing is automatically generated. This request includes the script parameters. Specify which parameters to use for selecting scripts for the configured pool:
сompany
. The company name in the cluster.-
operation
. The request type: script compilation or execution. Add one of the available values:сompile
orexecute
. For example, to process only script compilation, specify the configuration:
workerPoolCfg:
pools:
publishpool:
sources:
- operation: compile
type
. The system structure from which the script processing request was initiated. Specify one of the available values:process
. Business process.customactivity
. Business process action in the module.widget
. Widget.eventhandler
. Event handler.apihandler
. API method handler.
namespace
. The namespace of the system structure from which the script processing request was initiated. For example, for a workspace, this is its code.code
. The code of the system structure from which the script processing request was initiated. For example, the business process code, the code of the business process action in the module, etc.
The more conditions specified, the more precise the script selection for the pool. If a parameter is not filled in, it is not considered.
Examples of script selection configurations
workerPoolCfg:
workerPoolCfg:
workerPoolCfg:
workerPoolCfg: |
- Autoscaling pool parameters (
autoscaling
).
Depending on the load on the worker pool, configure settings for its automatic scaling. Based on these settings, the specified number of worker replicas will be created in the Kubernetes orchestrator. To do this, fill in the parameters in theautoscaling
block:
enabled
. Thetrue
value enables autoscaling.type
. The autoscaling method selection. Specify which tool to use. Available values:"hpa"
. Horizontal Pod Autoscaler. Used by default. No additional configuration is required."keda"
. Kubernetes event-driven autoscaling. Used if the additional KEDA component is configured.
-
minReplicas
. The minimum number of replicas in the pool. -
maxReplicas
. The maximum number of replicas in the pool.
- Additional pool options (
options
).
For server scripts, there is an execution timeout. If a script does not complete within this time, it is terminated. This prevents the pool from being blocked due to long script execution. To set timeouts, fill in the parameters in theoptions
section:
defaultScriptTimeoutSeconds
. The standard script execution timeout in seconds. After this time is up, script execution is terminated.maxScriptTimeoutSeconds
. The maximum script execution timeout in seconds. After this time is up, script execution is terminated.
Step 2: Apply the configured worker pool settings
Once you have configured the script selection and autoscaling parameters for worker pools in the values-elma365.yaml
file, apply the updated settings.
Use case: Configuring a dedicated pool for business process script processing
Suppose we have configured a dedicated worker pool in the values-elma365.yaml
file for the Create lead business process in the CRM workspace:
workerPoolCfg:
pools:
processpool: # The pool identifier is specified in free form using lowercase Latin letters and numbers, up to 20 characters long
sources:
- company: head # Company name
namespace: crm # Workspace code where the business process is created
operation: execute # Operation type — script execution
type: process # Only scripts from the business process are selected
code: createlead # Only scripts with the Create lead business process code are selected
autoscaling:
enabled: true
type: "hpa"
minReplicas: 1
maxReplicas: 9
After applying these settings, the following are automatically created:
- A worker pool in Kubernetes.
- A separate queue in RabbitMQ for this pool to distribute script processing requests for the Create lead business process.
When the Create lead process is launched in the system, a script processing request is automatically generated. This request includes the following data:
- Company:
head
. - Operation:
execute
. - System structure type:
process
. - System structure namespace:
crm
. - System structure code:
createlead
.
Since we specified this data in the dedicated worker pool settings, the request is automatically placed in this pool’s queue and executed within it.
Delete a configured worker pool
To delete a configured worker pool, remove the previously specified parameters from the values-elma365.yaml
file and apply them. After this, in RabbitMQ, all unprocessed script processing requests from its queue will be redirected to the script.default
queue. From there, they will be distributed among shared worker replicas.
Found a typo? Select it and press Ctrl+Enter to send us feedback