Long time before starting webhook execution

Hello faced such a problem as N8N’s long answer. The Waiting (TTFB) parameter is very large. However, it is stable. You always have to wait 1.4-1.5 seconds to start getting the first results. This happens with different workflows. When accessing direct and via reverse proxy nginx. Whatever we do, the response time remains unchanged. This is a problem, since, for example, a telegram bot reacts to a chat response for a long time, 1.5 seconds of waiting is added to each task execution.
Tell me what we can check or what can we fix to improve the situation?

Server VPS 2 core, 2Gb RAM, 32 GB SSD. The change in resources, both up and down, did not affect in any way.

Debian 10
n8n 0.86.1
nodejs v14.15.4
n8n is installed via npm install n8n -g

Here’s an example of a simple 3-node workflow. And the time taken to open the page. At the same time, in the n8n itself in history, it indicates that the execution was fast enough.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "path": "meshurlget",
        "responseMode": "lastNode",
        "options": {
          "responseContentType": "text/html; charset=utf-8",
          "responsePropertyName": "response",
          "rawBody": true
        }
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        450,
        300
      ],
      "webhookId": "bb24be26-f342-4b5f-918d-01689422432e"
    },
    {
      "parameters": {
        "functionCode": "item.nodeid = $node[\"Webhook\"].json[\"query\"][\"param\"].substr(6);\nreturn item;\n"
      },
      "name": "FunctionItem",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        650,
        300
      ],
      "notesInFlow": true,
      "notes": "Обрезаем лишнее"
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "response",
              "value": "=<head>\n</head>\n<body>\n<h1>Ссылка для доступа к рабочему столу</h1>\n<p>https://rm.realsd.ru/webhook/mesh?tab=desktop&nodeid={{$node[\"FunctionItem\"].json[\"nodeid\"]}}</p>\n<h1>Ссылка для доступа к терминалу</h1>\n<p>https://rm.realsd.ru/webhook/mesh?tab=terminal&nodeid={{$node[\"FunctionItem\"].json[\"nodeid\"]}}</p>\n<h1>Ссылка для доступа к файлам</h1>\n<p>https://rm.realsd.ru/webhook/mesh?tab=file&nodeid={{$node[\"FunctionItem\"].json[\"nodeid\"]}}</p>\n<h1>Общая ссылка доступа</h1>\n<p>https://rm.realsd.ru/webhook/mesh?nodeid={{$node[\"FunctionItem\"].json[\"nodeid\"]}}</p>\n</body>"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "FunctionItem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FunctionItem": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

The reason is that by defaults each execution starts in a new process which takes that long.

If you want to have a fast response you can tell n8n to run all the workflow executions in the same process. Then it will be very fast. You can do that by setting the following environment variable:

export EXECUTIONS_PROCESS=main

You can find the documentation here:

2 Likes

Oh yeah. It worked. Thanks a lot for the tip.