You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For each unique value of `concurrencyKey`, a new queue will be created using the `concurrencyLimit` from the queue. This allows you to have a queue per user.
223
+
213
224
### Lifecycle hooks
214
225
215
226
We've changed the function signatures of the lifecycle hooks to be more consistent and easier to use, by unifying all the parameters into a single object that can be destructured.
Copy file name to clipboardExpand all lines: docs/queue-concurrency.mdx
+16-17Lines changed: 16 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,11 @@ concurrency limit of your environment.
17
17
Each individual queue has a maximum concurrency limit equal to your environment's base concurrency limit. If you don't explicitly set a queue's concurrency limit, it will default to your environment's base concurrency limit.
18
18
19
19
<Note>
20
-
Your environment has a base concurrency limit and a burstable limit (default burst factor of 2.0x the base limit). Individual queues are limited by the base concurrency limit, not the burstable limit. For example, if your base limit is 10, your environment can burst up to 20 concurrent runs, but any single queue can have at most 10 concurrent runs. If you're a paying customer you can request higher limits by [contacting us](https://www.trigger.dev/contact).
20
+
Your environment has a base concurrency limit and a burstable limit (default burst factor of 2.0x
21
+
the base limit). Individual queues are limited by the base concurrency limit, not the burstable
22
+
limit. For example, if your base limit is 10, your environment can burst up to 20 concurrent runs,
23
+
but any single queue can have at most 10 concurrent runs. If you're a paying customer you can
24
+
request higher limits by [contacting us](https://www.trigger.dev/contact).
21
25
</Note>
22
26
23
27
## Setting task concurrency
@@ -75,6 +79,11 @@ When you trigger a task you can override the concurrency limit. This is really u
75
79
The task:
76
80
77
81
```ts /trigger/override-concurrency.ts
82
+
const paidQueue =queue({
83
+
name: "paid-users",
84
+
concurrencyLimit: 10,
85
+
});
86
+
78
87
exportconst generatePullRequest =task({
79
88
id: "generate-pull-request",
80
89
queue: {
@@ -98,12 +107,8 @@ export async function POST(request: Request) {
//every paid user gets a queue with a concurrency limit of 10
150
-
name: "paid-users",
151
-
concurrencyLimit: 10,
152
-
},
149
+
queue: "paid-users",
153
150
concurrencyKey: data.userId,
154
151
});
155
152
@@ -188,12 +185,14 @@ With our [task checkpoint system](/how-it-works#the-checkpoint-resume-system), t
188
185
Concurrency is only released when a run reaches a waitpoint and is checkpointed. When a run is checkpointed, it transitions to the `WAITING` state and releases its concurrency slot back to both the queue and the environment, allowing other runs to execute or resume.
189
186
190
187
This means that:
188
+
191
189
- Only actively executing runs count towards concurrency limits
192
190
- Runs in the `WAITING` state (checkpointed at waitpoints) do not consume concurrency slots
193
191
- You can have more runs in the `WAITING` state than your queue's concurrency limit
194
192
- When a waiting run resumes (e.g., when a subtask completes), it must re-acquire a concurrency slot
195
193
196
194
For example, if you have a queue with a `concurrencyLimit` of 1:
195
+
197
196
- You can only have exactly 1 run executing at a time
198
197
- You may have multiple runs in the `WAITING` state that belong to that queue
199
198
- When the executing run reaches a waitpoint and checkpoints, it releases its slot
0 commit comments