Slow http-request node

Describe the issue/error/question

Http-request node takes several seconds to do a simple GET request.

  • n8n it’s running in kubernetes with an external PG
  • assigning more resources (cpu/mem) does not change the results
  • Doing the whole flow in the console (curl) takes an avg of 4s
  • When webhook is set to immediate response, it only takes 0.2s

Are this numbers expected?

Any clue will be appreciated as I am going crazy with this issue

Please share the workflow

Information on your n8n setup

  • n8n version: 0.159.1
  • Database you’re using (default: SQLite): PG13
  • Running n8n with the execution process [own(default), main]: main
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: kubernetes

More debugging,

I set up n8n locally with docker and default options, when I run same experiment I get this:

So time is cut in half, still seems slow for such a simple flow but is much better, as expected, as all the laptop resources are available for n8n.

How could I debug where is the bottleneck?

If I use the default mode (not ‘main’) the time is 2x slower

The main factor would probably be that n8n has to wait until it receives a response from the server to which you make that request via the HTTP Request node. If you just want to see the speed of n8n itself, it is best to deactivate that HTTP Request Node but still leave the Webhook-Node set to return data of the last node (which would be in this case the Webhook-Node itself).

The only other thing I can currently think of that could cause a slowdown would be Postgres and the connection to it. If you also want to rule that out it is best to test with an SQLite database.

4 Likes

Hi jasl,

This looks very similar to an issue I had. Are you using SWAG from LSIO by any chance?

My thread is here - the solution sped it up quite a lot but still not as fast as when I access n8n directly via the IP (bypassing SSL).

Let me know if you find a better solution!

1 Like

I am also facing the same issue,
when n8n webhook is called for prod environment it takes 4 seconds to respond but
when n8n webhook is called for a local setup it takes 1.8 seconds whereas
API’s written without n8n responds in 750 milliseconds.
All the three test scenarios are used to query PostgreSQL database.

can you suggest some methods which we can follow to optimise(reduce) wait time
@jan @MutedJam @RicardoE105

Hey @LENINDALLAS,

Can you open a new thread and include how you have n8n setup, It would also be handy to know what you mean by local setup and prod environment and what the differences are between them.

@Jon local setup - n8n running in my system via n8n npm package
prod setup - n8n hosted in a server and n8n runs in a docker container.
I got the solution for slowness, when I added EXECUTIONS_PROCESS=main in env, now its blazing fast

2 Likes

That can be it, So when you use the default mode it fires up a process to handle it which can take a bit of time to do. Desktop I think has it set to main as a default option.

I also have this problem, but if you change to EXECUTIONS_PROCESS=main in env, all the workflows on that entire server is affected right? Or could you do this for a specific workflow?

Yeah it will impact all workflows, main will be quicker as it doesn’t have that wait time for the own process to start for each workflow run.

Ah ok, thank you. It didn’t really make a change for me though, have no idea why yet. I hire a very small virtual server on Hetzner so maybe it’s too weak.

What timings are you seeing? I would expect there to be a 2 or 3 second difference between the 2 options.

I get the same result, about 3-4 seconds on both, a very simple json return from a function. But as has been written here before, if I disconnect the function from the webhook and just choose immediate response I get like 40-50 ms.

I also have a n8n pro cloud account and there I get around 1 second, so much faster there too it seems, and I guess the cloud uses the own setting.

That is very odd, Can you share your workflow so I can test it on my local install? When you have been testing have you been using Docker, NPM or Desktop?

Sure, thanks for helping me!
It’s really almost nothing in there though, now I’m just testing with a webhook and a return function and it’s still the same:

Just tried a huge server on Hetzner and got it down to 2-3 seconds. Also, tried it on desktop and got 100-150 ms so there’s a huge difference at least. I must do something wrong with the EXECUTIONS_PROCESS=main.

How are you running n8n on the server? If we can get that and how you are setting the environment variable we should be able to get to the bottom of this one.

Will run the workflow shortly to see what happens.

I run it as a docker image as through your documentation here:
https://docs.n8n.io/hosting/server-setups/docker-compose/

Chose a larger machine on Hetzner again and got it down to 1,5-2 seconds. But executions=main still doesn’t do anything so maybe I’m doing something wrong with the .env-file?

Hey @ArtMooney,

Can you show me how you are setting that option?