Rate limit activity on all workers

I have read this post and this one.

But I don’t see how to rate limit the number of concurrent execution of an activity among all workers.
I can do maxConcurrentActivityExecutionSize on a worker, but if the service running the worker scale up by 1, then the rate will double. Any suggestion to implement this is appreciated.

Which SDK?

I am using Java SDK

Use WorkerOptions.MaxTaskQueueActivitiesPerSecond to rate limit task queue among all workers.

Thanks @maxim , the use case is that the activity worker will issue calls to backend which is a limited resource with quota, say 100 at a given time. Per second rate limiting is not going to help, Thinking maybe pull this worker out to its own and have a different scaling policy than other workers, set maxConcurrentActivityExecutionSize to 100 for that worker to limit it.
Any other builtin solution in Temporal?

Options:

  1. Write a workflow that is going to invoke those activities. Other workflows are going to request activity execution by sending signals to that workflow and waiting for reply signals. You might need to run more than one such workflow instance if a single workflow cannot keep up with the rate.
  2. Run a fixed number of workers and use per worker limit.
1 Like