Skip to content

Commit f39ebe5

Browse files
authored
Make configurable the number of concurrent workflows (#616)
1 parent 267d1ff commit f39ebe5

File tree

4 files changed

+64
-8
lines changed

4 files changed

+64
-8
lines changed

enduro.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ disabled = true
8585
processNameMetadata = false
8686

8787
[worker]
88-
heartbeatThrottleInterval = "60s"
88+
heartbeatThrottleInterval = "1m"
89+
maxConcurrentWorkflowsExecutionsSize = 15
90+
maxConcurrentSessionExecutionSize = 15
8991

9092
[workflow]
91-
activityHeartbeatTimeout = "20s"
93+
activityHeartbeatTimeout = "30s"

internal/workflow/semaphore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func acquirePipeline(ctx temporalsdk_workflow.Context, colsvc collection.Service
3333
// Acquire the pipeline semaphore.
3434
{
3535
ctx := temporalsdk_workflow.WithActivityOptions(ctx, temporalsdk_workflow.ActivityOptions{
36-
HeartbeatTimeout: time.Minute,
36+
HeartbeatTimeout: heartBeatTimeout,
3737
WaitForCancellation: false,
3838
ScheduleToStartTimeout: forever,
3939
StartToCloseTimeout: forever,

main.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,11 @@ func main() {
253253

254254
done := make(chan struct{})
255255
w := temporalsdk_worker.New(temporalClient, config.Temporal.TaskQueue, temporalsdk_worker.Options{
256-
EnableSessionWorker: true,
257-
MaxConcurrentSessionExecutionSize: 5000,
258-
MaxHeartbeatThrottleInterval: config.Worker.HeartbeatThrottleInterval,
259-
DefaultHeartbeatThrottleInterval: config.Worker.HeartbeatThrottleInterval,
256+
EnableSessionWorker: true,
257+
MaxConcurrentSessionExecutionSize: config.Worker.MaxConcurrentSessionExecutionSize,
258+
MaxConcurrentWorkflowTaskExecutionSize: config.Worker.MaxConcurrentWorkflowsExecutionsSize,
259+
MaxHeartbeatThrottleInterval: config.Worker.HeartbeatThrottleInterval,
260+
DefaultHeartbeatThrottleInterval: config.Worker.HeartbeatThrottleInterval,
260261
})
261262
if err != nil {
262263
logger.Error(err, "Error creating Temporal worker.")
@@ -402,7 +403,9 @@ type configuration struct {
402403
}
403404

404405
type WorkerConfig struct {
405-
HeartbeatThrottleInterval time.Duration
406+
HeartbeatThrottleInterval time.Duration
407+
MaxConcurrentSessionExecutionSize int
408+
MaxConcurrentWorkflowsExecutionsSize int
406409
}
407410

408411
func (c configuration) Validate() error {

website/content/en/docs/user-manual/configuration.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,57 @@ does not include a document with checksums, e.g. `checksum.sha1`.
462462

463463
E.g.: `false`
464464

465+
466+
### `[worker]`
467+
468+
#### `heartbeatThrottleInterval` (String)
469+
470+
Specifies the interval at which Enduro sends heartbeats to the workflow engine.
471+
472+
The string should be constructed as a sequence of decimal numbers, each with
473+
optional fraction and a unit suffix, such as "30m", "24h" or "2h30m".
474+
Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
475+
476+
E.g.: `5m` (String)
477+
478+
#### `maxConcurrentWorkflowsExecutionsSize` (int)
479+
480+
Sets the maximum number of concurrent workflow executions that Enduro will
481+
accept from the workflow engine.
482+
483+
A good rule of thumb is to set this value to twice the sum of the capacities
484+
of all the configured pipelines. For example, if two pipelines are configured
485+
with a capacity of `5` each, the value should be `20`.
486+
487+
E.g.: `10`
488+
489+
#### `maxConcurrentSessionExecutionSize` (int)
490+
491+
Sets the maximum number of concurrently running (workflow engine) sessions that
492+
Enduro supports. This value governs how many concurrent SIPs are going to be
493+
processed at any given time, regardless of pipeline
494+
capacity. This setting can be used to throttle from a single place how many
495+
concurrent pipelines Enduro will run.
496+
497+
We recommend setting this value to be directly proportional to (or higher than)
498+
the Archivematica pipeline capacity.
499+
500+
E.g.: `5`
501+
502+
### `[worker]`
503+
504+
#### `activityHeartbeatTimeout` (String)
505+
506+
Specifies the timeout duration for activities that send heartbeats to the workflow engine.
507+
If the activity takes more time to send a heartbeat to the workflow engine, the workflow will fail
508+
with a `heartbeatTimeout` error.
509+
510+
The string should be constructed as a sequence of decimal numbers, each with
511+
optional fraction and a unit suffix, such as "30m", "24h" or "2h30m".
512+
Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
513+
514+
E.g.: `5m` (String)
515+
465516
## Configuration example
466517

467518
Source: https://github.com/artefactual-labs/enduro/blob/main/enduro.toml.

0 commit comments

Comments
 (0)