Hi,
I would like my N8N not to execute workflows when another one is in the queue. To do this, I use regular execution mode with the argument: N8N_CONCURRENCY_PRODUCTION_LIMIT. When I launch a workflow with a schedule of 10 seconds and a wait time of 2 seconds, this happens:
my pm2 file :
cat ecosystem.regular.config.js
module.exports = {
apps: [
{
name: 'n8n',
script: 'n8n',
args: '',
instances: 1,
exec_mode: 'fork',
env: {
NODE_ENV: 'production',
N8N_PORT: 5678,
EXECUTIONS_MODE: 'regular', // Mode regular au lieu de queue
N8N_SECURE_COOKIE: 'false',
// Limiter la concurrence en mode regular
N8N_CONCURRENCY_PRODUCTION_LIMIT: 1, // Exécution séquentielle
// Database
DB_TYPE: 'postgresdb',
DB_POSTGRESDB_HOST: 'localhost',
DB_POSTGRESDB_PORT: 5432,
DB_POSTGRESDB_DATABASE: 'n8n',
DB_POSTGRESDB_USER: 'n8n_user',
DB_POSTGRESDB_PASSWORD: 'MonMotDePasseSecurise123!',
// Encryption key
N8N_ENCRYPTION_KEY: 'vGluJdTZ1rWDnytZT3X7D02l33OQ13aE'
}
}
]
};
Hi, @Necroun !
N8N_CONCURRENCY_PRODUCTION_LIMIT does not control when a workflow is triggered. It does not stop the trigger from firing and it does not cancel new executions. It only limits how many executions can run at the same time. Because of this, scheduled triggers will continue to create new executions, which are queued internally and start as soon as the running execution finishes. This is expected behavior.
If you need strict “one-at-a-time” behavior (no queued executions), you must implement a logical lock inside the workflow (for example using Redis, a database flag, or checking for running executions) or switch to queue mode with explicit control.
Do you have a exemple of pm2 config to “one-at-a-time” ?
@Necroun
Your PM2 configuration is already correct. The queuing issue must be solved at the workflow design level (Option 1 or 2) or by switching to queue mode (Option 3). There is no PM2-only solution for this.
3 Solutions to Achieve “One-at-a-Time” Execution:
Option 1: Adjust Your Workflow Schedule (Simplest)
- Change your schedule trigger interval to be longer than your workflow execution time
- Example: If workflow takes 2 minutes, set schedule to 3+ minutes
- This prevents overlapping executions
- No code or config changes needed beyond the schedule trigger
Option 2: Implement a Lock Inside Your Workflow (Keeps Regular Mode)
- Add logic at the start of your workflow to check if another execution is already running
- If running, abort immediately; if not, continue
- This requires modifying your workflow, not your PM2 config
- Can use: n8n API to check running executions, Redis lock, or database flag
Option 3: Switch to Queue Mode (Requires Redis)
- Better queue management but still allows queuing
- Requires Redis installation
- PM2 config change:
EXECUTIONS_MODE: 'queue' and add Redis connection variables
- Note: This still won’t prevent queuing, just manages it better
Can you help me, for the option 3, do you have model of pm2 ?