Round Robin Task Distributor using Data Tables - n8n Workflow

Implement a persistent Round Robin load balancer in your n8n workflow. This n8n template uses a Data Table and a Switch node to distribute tasks evenly across multiple routes.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Users scaling highly frequently called n8n workflows and needing distribution logic.

  • Developers needing reliable sequential task distribution logic.

  • n8n experts looking for advanced flow control n8n templates.

  • Anyone implementing robust core logic flow control using an n8n node.

Overview

This specialized n8n workflow addresses the challenge of scaling high-volume automation tasks by implementing a custom, persistent load-balancing mechanism. While n8n naturally handles parallel execution, this setup ensures strict, sequential, round-robin distribution across defined worker routes (Route 1, 2, 3). By using an n8n Data Table to persist the "Last Used" worker index, the n8n workflow reliably determines the next destination for the incoming job. This core logic flow control pattern is essential for separating resource-intensive operations into smaller, dedicated sub-workflows, enhancing stability and throughput. This advanced n8n template demonstrates powerful state management within n8n, ensuring fairness in task distribution.

How it Works


  1. Trigger and State Retrieval: The n8n workflow is initiated via an n8n trigger (currently manual). The process begins by using an n8n Data Table node to retrieve the persistent LastUsed index, indicating which worker route was utilized in the previous execution.

  2. State Calculation: A Code n8n node calculates the next route index. It reads the current value, increments it (1 -> 2 -> 3), and resets it to 0 if the index was 3, preparing for the next cycle.

  3. State Persistence: The n8n Data Table node is immediately updated with the newly calculated LastUsed value (1, 2, or 3), ensuring persistence across subsequent n8n workflow executions.

  4. Data Merging: A Merge n8n node combines the original input data received by the n8n trigger with the routing metadata containing the new route index.

  5. Routing: The Round Robin Router Switch n8n node evaluates the calculated Last_Used value and routes the execution data to the corresponding branch (Route 1, Route 2, or Route 3), completing the round-robin cycle. These route n8n nodes should be replaced with calls to actual worker sub-workflows.

Installation Guide


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n instance via the 'New' menu > 'Import from JSON'.

  2. Set up the Data Table: You must create an n8n Data Table named Load Balancer with at least two columns: id (string) and LastUsed (number).

  3. Initialize the Data Table: Insert a single row into the Load Balancer table. Set id to 1 and set LastUsed to 0 (or the starting route number).

  4. Configure Credentials (if needed): Ensure the Data Table n8n node is configured correctly to reference the newly created table.

  5. Customize Routes: Replace the placeholder Route 1, Route 2, and Route 3 No Op n8n nodes with Execute Workflow n8n nodes pointing to your actual worker sub-workflows or the full process logic you wish to distribute.

Node Details

When clicking ‘Execute workflow’ (Manual Trigger): The initial n8n trigger used for testing. For production, replace this n8n node with a Webhook or Schedule n8n trigger.
Calculate the next route to use (Data Table node): Functioned to retrieve the current state (LastUsed) from the Data Table before the core logic executes. Key operation: Get.
Code in JavaScript (Code node): Implements the sequential round-robin calculation: newValue = currentValue === 3 ? 0 : currentValue + 1;. This ensures cycling between indices 1, 2, and 3.
Update last
used in the datatable (Data Table node): Writes the calculated next index back to the Data Table using the Update operation, ensuring persistence for the next execution of this n8n workflow.
Merge trigger data to pass to subworkflow if needed (Merge node): Merges the original incoming data from the n8n trigger with the metadata calculated by the Code n8n node, ensuring the subsequent steps have all necessary information.
Round Robin Router (Switch node): The primary flow control n8n node. It checks the value of {{ $json.Last_Used }} and routes the execution to one of three corresponding outputs (1, 2, or 3).

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by

Business process improvement and continuous improvement SME. Process automation advocate.

Featured*