Latency issue with webhook

Hi guys,

the latency of calling webhook is very high, here is a simple comparaison between n8n and huginn

I’m using GitHub - codesenberg/bombardier: Fast cross-platform HTTP benchmarking tool written in Go to do fuzze testing, here is my command
.\bombardier.exe -c 125 -n 2000 --method POST url

here we send 2000 requests using 125 connections

using n8n webhook we have
Statistics Avg Stdev Max
Reqs/sec 9.67 88.86 1631.62
Latency 11.35s 520.13ms 13.90s

using higinn webhook we have
Statistics Avg Stdev Max
Reqs/sec 61.76 22.99 200.00
Latency 1.96s 305.21ms 4.21s

so 9s latency difference

I think because we do database call here that’s way we have this latency, we need to improve this guys

Welcome to the community @Anouar_BAKRI!

No the latency has less to do with the database more with n8n starting every workflow by default in a new process. This takes very long time. You can however simply tell it to start them in the main process by setting the environment variable EXECUTIONS_PROCESS=main. As soon as you do that it will be blazing fast.

if we have several processes to deal with it will get really slow especially the GUI I think !

we can just send a response immediately before calling this line of code
response = await this.activeWorkflowRunner.executeWebhook(‘POST’, requestUrl, req, res);
or we cache webhook config somewhere and use them directely from memory

thanks for fast response @jan really nice

Sadly not as we do not know what to respond with.

In the past it did cache the config in memory, that got however changed a while ago and will in the next week totally be served from a database with no information in memory anymore. It is maybe a bit slower but will make them stateless and so will scale easily. With the new design people can simply start multiple n8n instances, put a load-balancer in front of them and everything will scale horizontally.

2 Likes

Sadly not as we do not know what to respond with.

do we need to know ? because its just a webhook, as soon as we receive we can send immidiate response like this
ResponseHelper.sendSuccessResponse(res, “Event Recieved”, true, 200);

if we go to search for response it will become and API not a webhook,

As n8n allows to return the data of a workflow we need to know.

1 Like