Skip to main content

Prevent concurrent workflow runs using Redis

Workflow preview

Workflow preview
100%
Prevent concurrent workflow runs using Redis preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

What does this template do? This workflow sets a small "lock" value in Redis so that only one copy of a long job can run at the same time. If another trigger fires while the job is still busy, the ...

Best for

  • Engineering automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.executeworkflowtrigger, n8n-nodes-base.switch, n8n-nodes-base.manualtrigger, n8n-nodes-base.if, n8n-nodes-base.stickynote, n8n-nodes-base.executeworkflow, n8n-nodes-base.redis, n8n-nodes-base.set

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Hugues Stock.

Original n8n.io source

1.1 Workflow description

Title
Prevent concurrent workflow runs using Redis
Workflow name
Prevent concurrent workflow runs using Redis

What does this template do?

This workflow sets a small "lock" value in Redis so that only one copy of a long job can run at the same time. If another trigger fires while the job is still busy, the workflow sees the lock, stops early, and throws a clear error. This protects your data and keeps you from hitting rate limits.
Because the workflow also stores simple progress flags ("working", "loading", "finishing"), you can poll the current status and show live progress for very long jobs.

Use Case

Great when the same workflow can be called many times in parallel (for example by webhooks, cron jobs, or nested Execute Workflow calls) and you need an "only run once at a time" guarantee without building a full queue system.

What the Workflow Does

  • ⚡ Starts through Execute Workflow Trigger called by another workflow
  • 🔄 A Switch sends the run to Get, Set, or Unset actions
  • 💾 Redis reads or writes a key named process_status_<key> with a time‑to‑live (default 600 s)
  • 🚦 If nodes check the key and decide to continue or stop
  • ⏱️ Wait nodes stand in for the slow part of your job (replace these with your real work)
  • 📈 Updates the key with human‑readable progress values that another workflow can fetch with action = get
  • 🏁 When done, the lock is removed so the next run can start

Apps & Services Used

  • Redis
  • Core n8n nodes (Switch, If, Set, Wait, Stop and Error)

Pre‑requisites

  • A Redis server that n8n can reach
  • Redis credentials stored in n8n
  • A second workflow that calls this one and sends:
    • action set to get, set, or unset
    • key set to a unique name for the job
    • Optional timeout in seconds

Customization Tips

  • Increase or decrease the TTL in the Set Timeout node to match how long your job usually runs
  • Add or rename status values ("working", "loading", "finishing", and so on) to show finer progress
  • Replace Stop and Error with a Slack or email alert, or even push the extra trigger into a queue if you prefer waiting instead of failing
  • Use different Redis keys if you need separate locks for different tasks
  • Build a small "status endpoint" workflow that calls this one with action = get to display real‑time progress to users

Additional Use Cases

🛑 Telegram callback spam filter

If a Telegram bot sends many identical callbacks in a burst, call this workflow first to place a lock. Only the first callback will proceed; the rest will exit cleanly until the lock clears. This keeps your bot from flooding downstream APIs.

🧩 External API rate‑limit protection

Run heavy API syncs one after the other so parallel calls do not break vendor rate limits.

🔔 Maintenance window lock

Block scheduled maintenance tasks from overlapping, making sure each window finishes before the next starts.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When Executed by Another Workflow

Type / Role
n8n-nodes-base.executeWorkflowTrigger - executeWorkflowTrigger
Config choices
Version 1.1

Block 2 - Switch

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 3 - When clicking ‘Test workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 4 - If2

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 5 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Is Workflow Active

Type / Role
n8n-nodes-base.executeWorkflow - executeWorkflow
Config choices
Version 1.2

Block 8 - Set Workflow Active

Type / Role
n8n-nodes-base.executeWorkflow - executeWorkflow
Config choices
Version 1.2

Block 9 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 10 - Set Workflow Finished

Type / Role
n8n-nodes-base.executeWorkflow - executeWorkflow
Config choices
Version 1.2

Block 11 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Get Key

Type / Role
n8n-nodes-base.redis - redis
Config choices
Version 1

Block 13 - Set Key

Type / Role
n8n-nodes-base.redis - redis
Config choices
Version 1

Block 14 - UnSet Key

Type / Role
n8n-nodes-base.redis - redis
Config choices
Version 1

Block 15 - Set Timeout

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 16 - set continue

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 17 - If

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 18 - Is Workflow Active1

Type / Role
n8n-nodes-base.executeWorkflow - executeWorkflow
Config choices
Version 1.2

Block 19 - Stop and Error

Type / Role
n8n-nodes-base.stopAndError - stopAndError
Config choices
Version 1

Block 20 - No Operation, do nothing

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 21 - Set Workflow Active1

Type / Role
n8n-nodes-base.executeWorkflow - executeWorkflow
Config choices
Version 1.2

Block 22 - Set Workflow Finished1

Type / Role
n8n-nodes-base.executeWorkflow - executeWorkflow
Config choices
Version 1.2

Block 23 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Wait

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Showing the first 24 of 43 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Prevent concurrent workflow runs using Redis
Complexity advanced
Nodes 43
Categories Engineering
Author Hugues Stock
Published 10 May 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3976/3976.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Prevent concurrent workflow runs using Redis do?

What does this template do? This workflow sets a small "lock" value in Redis so that only one copy of a long job can run at the same time. If another trigger fires while the job is still busy, the ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering use case.