feat: Max task concurrency irrespective of the tenant queue
Is your feature request related to a problem? Please describe.
I have to process 1000s of images and I have third party api rate limit of 20 parallel processing. I want to allow user to be able to consume only 1 concurrency while maintaining task concurrency to 20 As soon as I use concurrency key it takes 1 per user but does not respect 20 limit and tasks start failing.
similar scenario, I like to process my order webhooks in parallel but I have to make sure I am processing webhooks for each order in sequence. I dont want to spin 100s of workers and block all other tasks while working on each order separately.
Describe the solution you'd like to see
There should be a config maxGlobalConcurrency: 10 in task definition and that should be respected when spinning workers. by default this value can be the global environment limit in case the value is not provided. this way there is no change needed to existing task definitions.
Describe alternate solutions
Not explored
Additional information
No response
Hi Trigger.dev team — I came across this request for a task-level global concurrency cap that still works alongside per-tenant / per-key concurrency, and built a small interactive proof of concept to explore the behavior.
The demo covers:
maxGlobalConcurrencystyle task-level limit- Per-user concurrency limits
- Queuing when the global cap is reached
- Burst simulation for large workloads
- External API rate-limit protection
- Running vs queued job visibility
Live demo: https://triggerdev-concurrency-control-demo.vercel.app
This is a proof of concept rather than a production implementation, but it demonstrates the scheduling behavior described in the issue. If the direction is useful, I'd be happy to discuss how it could map onto Trigger.dev's existing queue and worker model.
Hi @gautamsi, I'd be interested in contributing a production implementation of this feature.
I've worked with Redis-backed asynchronous job processing, backend services, and distributed systems, and this looks like an interesting scheduling challenge.
My initial approach would be to introduce a task-level maxGlobalConcurrency limit that works alongside existing per-key concurrency controls.
I'd investigate the current queue scheduling and concurrency enforcement mechanisms, then implement a solution that enforces both limits atomically, prevents over-dispatching, and releases capacity correctly when tasks complete, fail, or retry.
I'd also include tests for concurrent workers, per-key ordering, global limits, and backward compatibility.
I noticed the existing proof of concept and would focus on integrating this behavior into the actual scheduling infrastructure rather than building another demo.
Would the maintainers be open to this approach? I'd be happy to work on the implementation.