Best practices to optimize execution time

Hi all,

I was wondering if there is existing documentation / topic regarding the best practices for N8N workflows develpment to optimize the executions duration.

Here are some examples:

  • Is it better to add an “IF” node to set a field in a “EDIT FIELD” node depending on the condition
    OR
    directly define a field in a “EDIT FIELD” node with a If into an expression

  • I work on a workflow with many API calls to prepare a single payload.
    Is it better to make the API calls one after the other on the same branch and prepare the payload like this :
    {
    “field_1”: “{{ $(‘node1’).item.json.field_1 }}”,
    “field_2”: “{{ $(‘node2’).item.json.field_2 }}”,
    “field_3”: “{{ $(‘node3’).item.json.field_3 }}”
    }
    OR
    make the API calls on 3 branches, add a merge and prepare the payload like this :
    {
    “field_1”: “{{ $json.field_1 }}”,
    “field_2”: “{{ $json.field_2 }}”,
    “field_3”: “{{ $json.field_3 }}”
    }

I’ve just discovered this forum, sorry if the topic already exists but I wasn’t abble to find it.

Thank you very much in advance.

Best regards,

Adrien

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I havn’t come across a documentation of best practices yet.
For the two cases you mentioned I would go along this path:

  • Having an extra If node often makes it visually more understandable. I do not see a significant performance drop. So I would only prefer inline statements in a code node.
  • Both sequential and semi-parallel approaches have their own strengths and weaknesses. It is important to point out the current limitation of the merge node, which is that there is no possibility to access older notes prior to it. Also it can be more difficult or even impossible to handle both JSON and binaries at the same time. On the other hand it can get a bit messier when having to reference all nodes statically in a sequential setup. It is also important to make sure that every node has an output, so the workflow does not get stuck unintendedly. Using a merge node instead can skip empty branches when using the “Append” mode.
3 Likes

Ok, thank you for your answer :slight_smile:

1 Like