temporalio / temporalio/temporal

Resource-Aware Worker Concurrency

Open
#8,356 1 comment 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
23.2k
Forks
1.9k
Avg merge
2d 8h
Merged PRs (30d)
228

Description

Problem

Today, Temporal workers enforce concurrency with static limits (max_concurrent_activity_task_executions, max_concurrent_workflow_task_executions, etc.). These limits assume that workloads are uniform, but in practice workflows and activities have very different profiles (short IO-bound tasks vs. long CPU-bound tasks vs. memory-heavy ones).

This creates a false trade-off:

  • Set limits too low → workers are underutilized, leaving CPU/RAM idle and wasting money.
  • Set limits too high → workers oversubscribe, pods risk OOM/CPU thrash, and robustness is undermined.

Kubernetes autoscaling works on CPU/memory thresholds, but Temporal workers don’t adapt to that. The two systems don’t “speak the same language,” leading to either inefficiency or instability.


Proposed Direction

Introduce resource-aware concurrency controls in workers. For example:

  • Workers should stop polling when pod CPU/memory reaches configurable thresholds (e.g. 70–80%).
  • Concurrency could scale dynamically based on resource availability, rather than fixed magic numbers.
  • Optionally, expose hooks so operators can plug in their own resource metrics or scaling policies.

This would allow Temporal’s built-in backpressure to align with Kubernetes autoscaling, ensuring:

  • Pods never overload themselves.
  • Idle capacity is minimized.
  • Scaling is smooth and cost-efficient.

Why This Matters

Temporal’s core value proposition is reliability at scale. Without resource-aware workers, teams are forced to choose between:

  • Wasted resources (cost inefficiency).
  • Risky oversubscription (reliability gaps).

A resource-adaptive model would make Temporal more robust, cloud-native, and cost-efficient out of the box.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or implementation entry points are named. Start by locating the worker concurrency limits and polling/backpressure behavior, then determine how configurable CPU and memory thresholds or operator-provided metrics should interact with them; done requires an agreed design and tests covering resource-aware polling or concurrency changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.