Hello Guys,
when a webhook is invoked by postman the response is 1500-1600ms and the CPU usage is at this moment verry high for 1 process.
When i look at the execution time in n8n its only 0.053sec.
Webhooks are called via https if this makes any difference.
How can i improve the performance for webhooks and workflows?
1 Like
Welcome to the community.
Yeah, because by default a new process is created with each request. You can change this behavior by adding the env variable export EXECUTIONS_PROCESS=main
.
@shuimugan did just commit something which allows executing workflows in the main process. It can be activated like that:
export EXECUTIONS_PROCESS=main
It did not get released yet but you can already check out the code and test it like that. I hope it solves your problem. The memory consumption is that way now obviously much lower and workflows start immediately. Comes however with the mentioned trade-offs like just using a single CPU, workflows/main-process can block each other, …
3 Likes
The Performance difference is incredible!
Postman response before: 1500-1600ms
Postman response now: 40-50ms
Thank you!
Is there any benefit that the default setting for multi threads have?
jan
December 8, 2020, 6:41pm
4
Yes, the advantages are actually explained in the same topic here:
Yes, that is right. It got implemented like that on purpose. By starting multiple processes it makes sure that if multiple workflows run at the same time they use all available CPUs and do not block each other (which would be a big problem for CPU intensive tasks). Additionally, does it also make sure that if one execution crashes, all other executions and especially the main process run uninterrupted.
Honestly, am I also not the biggest fan of it. Less however because of the CPU usage but more…
1 Like
Thanks. I got a massive performance improvement with this.
The executions times went from the 6s-7s down to ~1s just with this. I can say that it’s reducing at least 4s of time just by changing this.
This is a lifesaver as we have a hard limit from the calling part of the webhook to reply within 5 seconds or it times out.
jan
February 4, 2021, 1:42pm
6
We will also soon merge this:
https://github.com/n8n-io/n8n/pull/1294
So if you have a lot of executions that should run in parallel you will be able to scale n8n like that across different machines.
1 Like