Skip to main content

Redis locking for concurrent task handling

Workflow preview

Workflow preview
100%
Redis locking for concurrent task handling preview
Open on n8n.io

Important notice

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

1. Workflow Overview

Who is this for? This workflow is great for n8n users who want to prevent duplicate or overlapping workflow runs . If you're a developer, DevOps engineer, or automation enthusiast managing tasks...

Best for

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

Tools used

n8n-nodes-base.noop, n8n-nodes-base.set, n8n-nodes-base.webhook, n8n-nodes-base.code, n8n-nodes-base.redis, n8n-nodes-base.if, n8n-nodes-base.wait, n8n-nodes-base.stickynote

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Redis locking for concurrent task handling
Workflow name
Redis locking for concurrent task handling

👤 Who is this for?

This workflow is great for n8n users who want to prevent duplicate or overlapping workflow runs. If you're a developer, DevOps engineer, or automation enthusiast managing tasks like database updates, syncing tools, or hitting rate-limited APIs, this one’s for you.


đź§© What problem does this solve?

In the real world, automations can get triggered at the same time—whether that’s because of multiple webhook calls, overlapping schedules, or retries. And when two workflows try to do the same thing at once (like updating a record or syncing data), it can cause conflicts, data corruption, or wasted API calls.

This workflow helps avoid that problem by using Redis as a lock system, so only one instance runs at a time. Think of it like putting up a “🚧 Workflow in Progress” sign while your logic is running.


⚙️ What this workflow does

  1. When the workflow starts, it tries to set a Redis key as a lock with a short expiry.
  2. If the lock is free:
    • Your main business logic runs.
    • Once it's done, the lock is cleared.
  3. If the lock is already taken (i.e., another run is in progress):
    • The workflow will wait and retry a few times.
  4. If a duplicate request shows up while one is already being processed:
    • It skips that duplicate to avoid unnecessary work.

You can customize both the timeout and retry logic to match your needs.


🛠️ Setup guide

To use this template:

  • You’ll need access to a Redis instance (either self-hosted or managed like Upstash, Redis Cloud, etc).
  • Set up your Redis credentials in the n8n Redis node.
  • Swap out the webhook node with your actual trigger or logic.
  • Adjust the lock timeout to match how long your task typically takes.

> đź’ˇ Bonus Tip: Use this pattern wherever you need idempotency or want to avoid duplicate processing.


đź§Ş Example use case

Let’s say you have a workflow that syncs ClickUp tickets to Google Sheets. It runs daily at 9 AM and updates tickets, adds notes, and makes sure nothing is missed.

But what if two runs start at the same time? Or someone triggers a manual sync while the scheduled one is still working?

By wrapping that whole sync inside this Redis locking template, you can make sure it only runs one at a time, saving your APIs (and your sanity).

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 - END

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

Block 2 - Workflow 1

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

Block 3 - Workflow 2

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

Block 4 - Workflow 3

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

Block 5 - Incoming Webhook Data

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 6 - Fetch Webhook Data & Declare lockValue

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 7 - Check Redis Lock

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

Block 8 - Acquire Redis Lock

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

Block 9 - redisLock existence boolean

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

Block 10 - redisLock acquired booleans

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

Block 11 - Poll for lock

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

Block 12 - duplicateWebhook boolean

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

Block 13 - Sticky Note

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

Block 14 - Discard Redis Lock

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

Block 15 - Sticky Note1

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

Block 16 - Workflow Switch

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

Block 17 - Sticky Note2

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

Block 18 - Sticky Note3

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

3. Summary Table

Workflow Redis locking for concurrent task handling
Complexity advanced
Nodes 18
Categories DevOps
Author Geoffrey Saxena
Published 06 Apr 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3444/3444.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 Redis locking for concurrent task handling do?

Who is this for? This workflow is great for n8n users who want to prevent duplicate or overlapping workflow runs . If you're a developer, DevOps engineer, or automation enthusiast managing tasks...

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 DevOps use case.