temporalio / temporalio/temporal

Allow multiple task queues to a worker - enables throttling of specific activities

Open
#7,916 1 comment 0 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

Is your feature request related to a problem? Please describe.
We need to throttle specific activities across all worker instances to not run more than a number per second. That's to not overload downstream.

Temporal task queues already can be configured to have a limit of activities run per second, so if we could register several task queues (with different limits), we could use specific queues for some activities that need throttling.

Describe the solution you'd like
Ability to attach several task queues to a worker. Each task queue can have it's TaskQueueActivitiesPerSecond configured independently.

worker.New(temporalClient, "your-task-queue-name", worker.Options{})

would now looks something like:

queues := []Queue{{
    "task-queue-fast",
    QueueOptions {
        TaskQueueActivitiesPerSecond: 100000,
    }},
    "task-queue-slow",
    QueueOptions {
        TaskQueueActivitiesPerSecond: 10,
    }},
}

worker.New(temporalClient, queues, worker.Options{})

then calling an activity, you can select what queue to send it to

newOptions := workflow.ActivityOptions{
	TaskQueue:          "task-queue-slow,
}
newCtx := workflow.WithActivityOptions(ctx, newOptions)
err := workflow.ExecuteActivity(newCtx, ThrottledActivity, name).Get(ctx, &result)

Describe alternatives you've considered
Alternatives available:

  • have copies of the same worker register to the same task queue - requires several instances of the worker
  • do the throttling using an external system - e.g. redis/db etc

Additional context
This is a very common setup which all projects calling downstream API endpoints would be able to use.

I am happy to give it a go at raising a PR for it if you think this is something you'd like to include.

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

Start by tracing the worker.New entry point and the TaskQueueActivitiesPerSecond option through the worker and workflow activity-routing implementation. Review existing worker and task-queue tests before defining coverage for multiple queues, independent limits, and activity selection; done means each configured queue can throttle separately and activities can target the intended queue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.