Introducing a new way to review your PRs.

Read the announcement

hatchet-dev / hatchet

🪓 An orchestration engine for background tasks, AI agents, and durable workflows

View on GitHub

31 documents · Updated Nov 23, 2026

docs / concurrency-controls

Concurrency controls

Concurrency controls limit how many workflow runs can use the same execution capacity at one time. A tenant can define controls at shared, workflow, or task scope, group runs with a key expression, and apply a limit policy. The concurrency view brings these controls together with live running and queued work so an engineer can find pressure points and inspect the keys that cause them. See Workflow orchestration for the wider run model and Run dispatch and queue execution for queue behavior.

Concurrency strategy model

Strategy scopes

A concurrency strategy is a capacity rule attached to a level of workflow execution. Its scope tells the system which runs share the limit and tells the console where the rule belongs.

ScopeCapacity boundaryConsole context
SharedOne pool used by tasks across workflowsLists the tasks and workflows that use it
WorkflowRuns of a workflow versionLinks to the workflow and version
TaskRuns of one task in a workflow versionLinks to the workflow, task, and version

The overview favors the current workflow versions. It also keeps a strategy from an older version visible while active runs still hold its slots. The console marks this state as draining so an operator can distinguish an active rule from capacity that is waiting to clear.

References: pkg/…/concurrency_overview.go• L25-33 pkg/…/concurrency_overview.go• L45-66 pkg/…/concurrency_overview.go• L166-341

Keys and limits

A key expression divides work under a strategy into separate capacity pools. Each key has its own maximum run count, running count, queued count, and oldest queued time. A strategy can use one fixed maximum or a maximum derived from run input; the view shows the configured expression when the limit is dynamic.

The limit strategy describes what happens when a key reaches its capacity. The supported policy labels are:

  • Group round robin.
  • Cancel in progress.
  • Cancel newest.
  • Cancel queued except newest.
  • Cancel queued except oldest.
  • No cancellation policy.

These settings govern how new work competes for a full key. The concurrency page exposes the settings and current load; it does not replace the workflow or task configuration that defines them. See Public API contracts for the client-facing data contract.

References: pkg/…/concurrency_overview.go• L68-79 pkg/…/concurrency_overview.go• L89-96 frontend/…/concurrency-format.ts• L26-42 frontend/…/strategies-panel.tsx• L149-179

Capacity overview

Strategy inventory

The tenant overview presents all visible strategies with their scope, key expression, limit policy, maximum runs, key count, running count, queued count, and oldest queued age. It sorts the most constrained strategies first by queued runs, then by the oldest queued work, so the view directs attention to current capacity pressure.

The page also gives tenant-wide totals for strategies, active keys, runs holding slots, queued runs, and the longest queue age. These totals provide a quick capacity signal before an engineer opens one strategy for detail.

The page refreshes through the normal client polling path and keeps elapsed queue time moving between refreshes. The data is briefly cached per tenant, so the display is an operational view rather than an exact transaction-time snapshot.

References: pkg/…/concurrency_overview.go• L17-23 pkg/…/concurrency_overview.go• L98-107 pkg/…/concurrency_overview.go• L343-359 frontend/…/totals-strip.tsx• L18-88 frontend/…/strategies-panel.tsx• L69-119

Key inspection

Selecting a strategy opens its keys in a side panel. The panel shows the key value, slot use against its maximum, queued runs, and the age of the oldest queued run. Search narrows the keys, and pagination keeps large key sets usable.

The key list can be opened from a strategy row, from the longest-queued total, or from a URL that names a strategy. Closing the panel clears that selection from the URL. If the strategy disappears before the panel loads, the panel reports that it no longer exists instead of showing stale detail.

The list supports a queued-only filter at the data layer, although the current page uses search and paging as its main controls. This makes the same overview data useful for both broad capacity review and focused queue investigation.

References: pkg/…/concurrency_overview.go• L81-107 pkg/…/concurrency_overview.go• L369-503 frontend/…/keys-panel.tsx• L47-59 frontend/…/keys-panel.tsx• L128-175 frontend/…/index.tsx• L82-135

Client access and tenant boundary

Tenant overview service

The V1 concurrency service is the server-side entry point for tenant concurrency overview access. The repository reads strategies and slot statistics through tenant-scoped data access, then returns a common summary shape for shared, workflow, task, and draining strategies.

The strategy identity combines its scope and numeric ID. This prevents an ID from one scope from being confused with an ID from another scope when the client selects a strategy or requests its keys.

References: api/…/service.go• L7-16 pkg/…/concurrency_overview.go• L98-107 frontend/…/concurrency-format.ts• L7-9

Client view state

The page keeps the selected strategy and strategy page in the URL. The key search and key page stay in the side panel because they belong to the selected inspection session. Client polling updates both strategy summaries and key detail without changing the tenant or selected strategy.

The page is available only when the concurrency feature is enabled for the tenant. Otherwise the route returns the standard not-found view, which keeps an unavailable operational feature out of the client surface.

References: frontend/…/index.tsx• L21-36 frontend/…/index.tsx• L45-66 frontend/…/search.ts• L3-16 frontend/…/use-concurrency.ts• L9-47

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the scope and strategy identity contract aligned between summary data, key lookup, URL state, and side-panel selection.
  • Keep draining strategies visible until their old runs release slots; removing them early hides capacity that is still in use.
  • Keep summary counts and key counts tied to the same tenant boundary and strategy scope.
  • Keep dynamic maximum-run values distinct from fixed maximums in both the client contract and the console display.
  • Keep queue sorting and longest-queued links aligned so an operator can move from the tenant signal to the responsible key.

Important failure modes

TriggerConsequenceGuard
A strategy ID is resolved without its scopeThe client can open the wrong strategy or fail to find its keysUse the combined scope-and-ID strategy reference
An older workflow version still has active slotsHiding its strategy makes capacity appear freeInclude it as draining until its slots clear
Summary data and key data use different tenant or scope filtersCounts and detail disagreeApply tenant-scoped queries and validate the strategy before listing keys
Queue data is read during a brief cache windowThe page can lag behind live execution stateTreat the view as a polled operational snapshot

Key files

FileWhy to read it
pkg/…/concurrency_overview.goDefines the tenant-level strategy and key view, including scopes, slot counts, draining state, sorting, and lookup rules.
api/…/service.goMarks the V1 server boundary for tenant concurrency overview access.
frontend/…/index.tsxShows how the page combines strategy summaries, totals, selection, refresh, and key inspection.
frontend/…/strategies-panel.tsxShows the strategy-level capacity signals and their operational sort order.
frontend/…/keys-panel.tsxShows the per-key view used to inspect running and queued work.
frontend/…/use-concurrency.tsShows the client polling and paging contract for strategies and keys.