Prevent concurrent workflow runs using Redis

Used in n8n, this workflow prevents concurrent executions by managing workflow states through Redis. It ensures that only one instance runs at a time, avoiding conflicts and errors. By setting and unsetting keys, it tracks the workflow's status, allowing for efficient resource management and clear visibility of ongoing processes. This automation enhances reliability and reduces the risk of overlapping tasks, ultimately improving operational efficiency.

7/8/2025
43 nodes
Complex
manualcomplexexecuteworkflowtriggersticky noteexecuteworkflowredisstopanderrornoopwaitadvancedlogicroutingconditional
Categories:
Complex WorkflowManual TriggeredData Processing & AnalysisBusiness Process Automation
Integrations:
ExecuteWorkflowTriggerSticky NoteExecuteWorkflowRedisStopAndErrorNoOpWait

Target Audience

Target Audience


- Developers: Those looking to automate workflows without manual intervention.
- Project Managers: Individuals needing to track the status of concurrent tasks in real-time.
- Operations Teams: Teams that require a mechanism to prevent overlapping executions of workflows.
- Data Engineers: Professionals who need to manage and monitor workflow executions efficiently.
- Businesses: Organizations aiming to optimize their operational processes and reduce errors from concurrent executions.

Problem Solved

Problem Solved


This workflow addresses the issue of concurrent executions of workflows that can lead to data inconsistency, overlapping processes, and execution errors. By leveraging Redis to track the status of workflows, it ensures that only one instance of a workflow can run at a time, thereby preventing conflicts and ensuring reliable operations.

Workflow Steps

Workflow Steps


1. Manual Trigger: The workflow begins when a user manually triggers it.
2. Set Timeout: It sets a timeout period (default 600 seconds) to keep track of the workflow's active status.
3. Check Active Status: It checks if the workflow is already active by querying Redis. If it is active, it stops execution and raises an error.
4. Set Active Status: If the workflow is not active, it sets its status to 'working' in Redis.
5. Execute Workflow Logic: The workflow then proceeds to execute its main logic, which can involve multiple steps or tasks.
6. Update Status: After completing tasks, it updates the status to 'finished' in Redis.
7. Unset Key: Finally, it unsets the key in Redis to indicate that the workflow has completed, allowing future executions.

Customization Guide

Customization Guide


- Adjust Timeout: Users can modify the timeout value in the Set Timeout node to increase or decrease the time the workflow should be considered active.
- Change Workflow Logic: Modify the main logic section of the workflow to include specific tasks that suit your needs.
- Redis Key Naming: Change the Redis key format in the Get Key, Set Key, and UnSet Key nodes to reflect your unique workflow identifiers.
- Add More Conditions: Users can expand the logic by adding more conditions in the Switch nodes to handle additional actions or states.
- Integrate with Other Services: Users can integrate this workflow with other services or APIs by adding additional nodes as necessary.