Prevent Concurrent Workflow Runs With Redis
detail.loadingPreview
Ensure your n8n workflows run exclusively by leveraging Redis for locking mechanisms. This solution prevents multiple instances of the same workflow from executing simultaneously, safeguarding data integrity and resource usage.
About This Workflow
This n8n workflow template provides a robust solution to prevent concurrent executions of any given workflow. It utilizes Redis as a distributed locking mechanism. When a workflow is triggered, it first checks with Redis if another instance is already active for the same key. If not, it sets a lock; otherwise, it prevents the new instance from proceeding. This is crucial for processes that should only run one at a time, such as critical data processing or resource-intensive tasks. The workflow offers clear input parameters for defining the lock key, action (get, set, unset), and a timeout to automatically release locks, ensuring reliability and preventing deadlocks.
Key Features
- Redis-Powered Locking: Utilizes Redis for reliable, distributed locking to prevent simultaneous workflow runs.
- Action-Based Control: Supports
get,set, andunsetactions for comprehensive lock management. - Configurable Lock Keys: Easily define unique keys to manage locks for specific workflows or processes.
- Timeout Mechanism: Includes a timeout feature to automatically release locks, preventing deadlocks.
- Workflow Trigger Integration: Designed to be triggered by other workflows or manually for testing.
How To Use
- Integrate the Workflow: Import this workflow into your n8n instance. It's designed to be called by another workflow.
- Define Inputs: When calling this workflow from another, provide the following inputs:
action: Specifyget(to check if a lock exists),set(to acquire a lock), orunset(to release a lock).key: A unique string identifier for the workflow or process you want to lock (e.g., 'order_processing_workflow').value(optional forset): The value to store with the lock, defaults to 'working'.timeout(optional forset): The duration in seconds before the lock automatically expires.
- Configure Redis Connection: Ensure your n8n instance is correctly configured to connect to your Redis server.
- Implement Calling Logic: In your primary workflow, use the 'Execute Workflow' node to call this concurrency control workflow before executing the main logic. Check the output of the 'Execute Workflow' node. If the output indicates no concurrent run (e.g., the
If2node evaluates to true), proceed with your main workflow logic. If a lock is already set, you can choose to wait, retry, or abort the current execution.
Apps Used
Workflow JSON
{
"id": "a7b0d1c1-9d8e-4b8b-904b-f4e0d962855f",
"name": "Prevent Concurrent Workflow Runs With Redis",
"nodes": 6,
"category": "DevOps",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: a7b0d1c1-9d8e...
About the Author
AI_Workflow_Bot
LLM Specialist
Building complex chains with OpenAI, Claude, and LangChain.
Statistics
Related Workflows
Discover more workflows you might like
Automate Qualys Report Generation and Retrieval
Streamline your Qualys security reporting by automating the generation and retrieval of reports. This workflow ensures timely access to crucial security data without manual intervention.
Automated PR Merged QA Notifications
Streamline your QA process with this automated workflow that notifies your team upon successful Pull Request merges. Leverage AI and vector stores to enrich notifications and ensure seamless integration into your development pipeline.
Visualize Your n8n Workflows: Interactive Dashboard with Mermaid.js
Gain unparalleled visibility into your n8n automation landscape. This workflow transforms your n8n instance into a dynamic, interactive dashboard, leveraging Mermaid.js to visualize all your workflows in one accessible place.