This documentation is available to agents as Markdown at https://docs.synthesized.io/tdk/latest/user_guide/050_deployment_operations/production_setup/multi_worker.md. For the complete documentation index, see llms.txt.

Multiple Workers

Workers take queued runs from Governor independently. To run more workflows at once, run more workers. No other coordination is needed.

Kubernetes (Helm)

Set the number of workers with worker.replicaCount in your values.yaml:

worker:
  replicaCount: 2
  container:
    config:
      WORKER_DATASOURCES: '*'

Then apply it:

helm upgrade governor oci://synthesizedio.jfrog.io/helm/governor \
  -f values.yaml \
  --reuse-values

Each replica registers with Governor under its own ID, and checks for queued runs every 2 seconds.

Groups WORKER_DATASOURCES Effect

Any (default)

'*'

The workers take runs for any data source.

One group

'<group-name>'

The workers take only runs whose input and output data sources both have the Worker group <group-name>.

All replicas share the same settings. For workers with different groups, for example one set per network, run extra workers next to those databases, as described in Synthesized Workers.

The chart sets tlsInternal.enabled: false and WORKER_USEPLAINTEXT: "true" by default, so the gRPC connection between workers and Governor isn’t encrypted. To encrypt it, do one of these:

  • Set tlsInternal.enabled: true to use the chart’s built-in mutual TLS, with Envoy sidecars. The chart then sets WORKER_SERVERHOST, WORKER_SERVERPORT and WORKER_USEPLAINTEXT itself, so don’t set them. The chart doesn’t install cert-manager or create the certificate issuer, so first:

    • install cert-manager in the cluster;

    • create a ClusterIssuer named internal-ca-issuer, or point tlsInternal.certificates.issuerRef at your own issuer;

    • create the CA secret internal-ca-cert with the key ca.crt in the release namespace, or set tlsInternal.certificates.ca.bundled: true to use the ca.crt that cert-manager puts in each certificate secret;

    • create an image pull secret for dhi.io, where the Envoy sidecar image comes from by default. See the comments on tlsInternal in the chart’s values.yaml.

  • Keep tlsInternal.enabled: false and use your own certificates, as described in Worker–Governor mTLS.

Docker Compose

Identical workers

To run several identical workers, scale the worker service with the docker-compose.multi-worker.yml overlay:

docker compose \
  -f docker-compose.yml \
  -f docker-compose.override.yml \
  -f docker-compose.multi-worker.yml \
  up --scale worker=3 --detach

The overlay removes the worker’s fixed host port binding, so the replicas don’t all try to bind port 8083 on the host. Port 8083 stays reachable inside the Docker network.

All replicas share the same AGENT_DATASOURCES and AGENT_TAGS. They appear in Administration > Workers with different IDs and the same tags, and any of them can take any run that matches. The Data source tags column shows each worker’s groups; * means any group.

Workers page showing three scaled workers with wildcard data source tags

Workers with different groups

--scale can’t give replicas different settings. For workers that serve different groups, or have different tags, define a separately named worker service for each, with its own AGENT_DATASOURCES and AGENT_TAGS. Then set each data source’s Worker group to match.

In the demo

On a fresh volume, the overlay also sets up a second output for the demo:

What How

A second output database, output_source_2

Created by initdb/create_output_db2.sql

A second output data source in Governor

Added by initdb/create_governor_data_multi_worker.sql

The Masking workflow writing to the second output

Set by the same file

The initdb scripts run only on a fresh volume. If you started the demo before, either recreate the volumes with docker compose down -v, which deletes all data, or create the output database and data source yourself in Governor.

Data sources page showing the input

Give each workflow its own output

Two workflows that run at the same time must write to different output databases. If they share one, the second fails straight away with:

Failed to claim sink. TDK is already running. Sink is already claimed by [<user>] at <timestamp>.

The output databases can be on the same database server, as long as the database names differ. Create one for each workflow that runs at the same time, and set it as that workflow’s output.

Limit database resources

Concurrent runs put more load on the databases. If your test databases run in Kubernetes, set memory limits on their pods, and cap the database’s own memory use, so they don’t run out of memory under load. For SQL Server, for example:

env:
  - name: MSSQL_MEMORY_LIMIT_MB
    value: "2048"
resources:
  requests:
    memory: "2Gi"
    cpu: "1"
  limits:
    memory: "3Gi"
    cpu: "2"

Use the equivalent setting for other databases.

Docker Compose and Helm compared

Docker Compose Kubernetes (Helm)

Variable prefix

AGENT_*

WORKER_*

Worker groups

AGENT_DATASOURCES

WORKER_DATASOURCES

How to add workers

--scale worker=N with the overlay, or named worker services

worker.replicaCount: N

Port conflicts when scaling

Solved by the overlay

None: each pod has its own address