Master Inngest flow control mechanisms to manage resources, prevent overloading systems, and ensure application reliability. This skill covers all flow control options with prescriptive guidance on when and how to use each.
These skills are focused on TypeScript.
For Python or Go, refer to the
Inngest documentation
for language-specific guidance. Core concepts apply across all languages.
Quick Decision Guide
"Limit how many run at once"
→ Concurrency
"Spread runs over time"
→ Throttling
"Block after N runs in a period"
→ Rate Limiting
"Wait for activity to stop, then run once"
→ Debounce
"Only one run at a time for this key"
→ Singleton
"Process events in groups"
→ Batching
"Some runs are more important"
→ Priority
Concurrency
When to use:
Limit the number of executing steps (not function runs) to manage computing resources and prevent system overwhelm.
Key insight:
Concurrency limits active code execution, not function runs. A function waiting on
step.sleep()
or
step.waitForEvent()
doesn't count against the limit.
Basic Concurrency
inngest
.
createFunction
(
{
id
:
"process-images"
,
concurrency
:
5
}
,
{
event
:
"media/image.uploaded"
}
,
async
(
{
event
,
step
}
)
=>
{
// Only 5 steps can execute simultaneously
await
step
.
run
(
"resize"
,
(
)
=>
resizeImage
(
event
.
data
.
imageUrl
)
)
;
}
)
;
Concurrency with Keys (Multi-tenant)
Use
key
parameter to apply limit per unique value of the key.
inngest
.
createFunction
(
{
id
:
"user-sync"
,
concurrency
:
[
{
key
:
"event.data.user_id"
,
limit
:
1
}
]
}
,
{
event
:
"user/profile.updated"
}
,
async
(
{
event
,
step
}
)
=>
{
// Only 1 step per user can execute at once
// Prevents race conditions in user-specific operations
}
)
;
Account-level Shared Limits
inngest
.
createFunction
(
{
id
:
"ai-summary"
,
concurrency
:
[
{
scope
:
"account"
,
key
:
`
"openai"
`
,
limit
:
60
}
]
}
,
{
event
:
"ai/summary.requested"
}
,
async
(
{
event
,
step
}
)
=>
{
// Share 60 concurrent OpenAI calls across all functions
}
)
;
When to use each:
Basic: Protect databases or limit general capacity