-
Notifications
You must be signed in to change notification settings - Fork 3.7k
perf(trigger): cap concurrency on background DB tasks #5231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { env, envNumber } from '@/lib/core/config/env' | ||
|
|
||
| /** Per-task Trigger.dev concurrency caps. Bound heavy DB tasks so unbounded fan-out can't saturate the pool. */ | ||
|
|
||
| export const WORKFLOW_EXECUTION_CONCURRENCY_LIMIT = envNumber( | ||
| env.WORKFLOW_EXECUTION_CONCURRENCY_LIMIT, | ||
| 75, | ||
| { min: 1, integer: true } | ||
| ) | ||
|
|
||
| export const WEBHOOK_EXECUTION_CONCURRENCY_LIMIT = envNumber( | ||
| env.WEBHOOK_EXECUTION_CONCURRENCY_LIMIT, | ||
| 75, | ||
| { min: 1, integer: true } | ||
| ) | ||
|
|
||
| export const RESUME_EXECUTION_CONCURRENCY_LIMIT = envNumber( | ||
| env.RESUME_EXECUTION_CONCURRENCY_LIMIT, | ||
| 50, | ||
| { min: 1, integer: true } | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ import { | |
| wasExecutionFinalizedByCore, | ||
| } from '@/lib/workflows/executor/execution-core' | ||
| import { handlePostExecutionPauseState } from '@/lib/workflows/executor/pause-persistence' | ||
| import { WORKFLOW_EXECUTION_CONCURRENCY_LIMIT } from '@/background/concurrency-limits' | ||
| import { ExecutionSnapshot } from '@/executor/execution/snapshot' | ||
| import type { ExecutionMetadata } from '@/executor/execution/types' | ||
| import { hasExecutionResult } from '@/executor/utils/errors' | ||
|
|
@@ -206,5 +207,8 @@ export async function executeWorkflowJob(payload: WorkflowExecutionPayload) { | |
| export const workflowExecutionTask = task({ | ||
| id: 'workflow-execution', | ||
| machine: 'medium-1x', | ||
| queue: { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| concurrencyLimit: WORKFLOW_EXECUTION_CONCURRENCY_LIMIT, | ||
| }, | ||
| run: executeWorkflowJob, | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When these constants are evaluated before the Trigger worker has the new env vars in
process.env,envNumberfalls back to75and the override is never read again. In deployments where Trigger-specific env vars are only injected through the Trigger project/runtime settings, loweringWORKFLOW_EXECUTION_CONCURRENCY_LIMITwould be silently ignored and the task can keep running at the default cap.