Parallel API
In Nected, workflows are flexible and support multiple patterns for executing REST APIs concurrently. Whether you’re making API calls to fetch data from external sources, trigger third-party services, or synchronize platforms, executing these calls in parallel significantly improves performance and reduces latency.
There are three supported approaches to achieve parallel API execution within a workflow:
1. Using a Single Rule (Recommended for API-only Flows)
This method is ideal when you need to call multiple APIs together and process their responses jointly.
Steps to Execute APIs in Parallel Using a Single Rule:
Navigate to Rule Editor:
Open an existing rule or create a new Simple Rule.
Configure Input Attributes:
Add each REST API you want to call as an input attribute. These will act as parallel API sources.
For each API, configure the input as an API fetcher that calls the respective endpoint.
Define Output (Result):
In the 'Result' section, reference all the API response values you configured in input attributes.
You can combine them into one object or return them individually.
Use the Rule in Workflow:
Go to your workflow.
Add a Rule Node and select the configured rule.
All APIs configured in the input attributes will now be triggered in parallel when the workflow reaches this node.
Input attributes are evaluated in parallel by default in Nected, so this setup ensures that all APIs run concurrently.
When this method is useful?
The Single Rule method works best when you have a fixed set of independent APIs that need to execute simultaneously without complex processing logic between them. This approach excels in scenarios where you want to aggregate data from multiple sources quickly and efficiently, treating each API as a simple data fetcher rather than requiring sophisticated business logic or conditional processing for individual calls.
2. Using a RuleSet (Recommended When Each API Has Its Own Logic)
This method is best suited when each API requires independent pre-processing or post-processing logic.
Steps to Use RuleSet for Parallel API Execution:
Create Individual Rules:
Create a separate rule for each API call.
Each rule should handle just one API (and optionally its transformation).
Create a RuleSet:
Navigate to Rule Editor and choose RuleSet.
Add all the rules you created.
The RuleSet will now invoke all the selected rules in parallel.
Use the RuleSet in Workflow:
In your workflow, add a Rule Node.
Choose the RuleSet from the dropdown.
On execution, all rules inside the RuleSet—and hence all APIs—will be called in parallel.
The collective output of all rules in the RuleSet will be available in a single response object.
When this method is useful?
The RuleSet method becomes essential when your parallel API calls require different business logic, validation rules, or data transformation processes for each endpoint. Unlike the Single Rule approach where APIs act as simple data fetchers, RuleSet excels when each API call needs its own intelligent processing layer. This method provides modular separation of concerns, allowing you to maintain, version, and modify the logic for each API independently while still executing them concurrently.
3. Using Loop Node + Switch Block (Advanced Configuration)
This method is useful when you need to conditionally trigger different APIs in parallel based on dynamic inputs.
Steps to Use Loop + Switch for Parallel API Calls:
Create a Helper Workflow with Switch Block:
Open Workflow Editor.
Add a Switch Block node.
Create a case for each API call (e.g., case = "PARALLEL_1", case = "PARALLEL_2").
Inside each case, add a REST API Node to call the respective API.
Publish this helper workflow.
Use Loop Node in Main Workflow:
In your primary workflow, add a Loop Node.
Set the loop input as a list of case values (e.g.,
["PARALLEL_1", "PARALLEL_2", "PARALLEL_3"]
).Set concurrency equal to the number of parallel APIs you wish to run.
Invoke Switch Workflow via Loop:
Inside the loop, add a Workflow Node.
Select the helper workflow with the Switch Block.
Pass the case input to the switch logic using a mapped variable (e.g.,
apiName
).
The Loop Node will concurrently run multiple instances of the Switch workflow, executing all matched APIs in parallel.
When this method is useful?
The Loop Node + Switch Block method becomes invaluable when your parallel API execution requirements depend on dynamic conditions, variable inputs, or complex decision-making logic that determines which APIs should be called and how many times. This advanced approach excels in scenarios where the execution pattern isn't fixed but instead adapts based on runtime data, user attributes, or business rules. Unlike the previous methods that work with predetermined API sets, this method provides sophisticated control over parallel execution flow, making it ideal for applications that need intelligent, conditional API orchestration.
Summary
Parallel API execution in Nected workflows dramatically improves performance by eliminating sequential wait times and optimizing resource utilization. Whether you're aggregating data from multiple sources, processing independent business logic, or implementing dynamic conditional routing, choosing the right parallelization method ensures optimal workflow efficiency.
Here is a brief table of the 3 methods and what they're mostly suitable for:
Single Rule
Simple API fan-out scenarios
Low
All APIs as input attrs
RuleSet
Independent logic or pre-processing for each API
Medium
Rules executed in parallel
Loop + Switch Block
Dynamic execution based on conditions or arrays
High
Workflows run in parallel
Each method provides significant performance gains over sequential execution while maintaining clean, maintainable workflow architecture. Start with the simplest approach that meets your requirements, and scale to more sophisticated patterns as your integration complexity grows.
Last updated