How concurrent webhooks are processed on a single n8n instance?

Dear n8n community!
I’d like to ask how the multiple webhook requests work. I have read this page, but it doesn’t provide an answer about simple n8n installations.

I have a single n8n installation on a VPS (4 Gb RAM, 2vCPUs) in a Docker (I didn’t set up anything regarding workers counts or main/worker instances of n8n).

  • My workflow listens to a trigger node (from some messenger app), then processes the data.
  • Each time workflow is triggered, it will run for 5-8 secs.
  • It does some CPU-intensive calculations and pings external sources (so it cannot work much faster than that).
  • In the end, some text message is sent back to the user.

What will happen if the workflow receives, let’s say, 10 messages from different users within one second?

  1. Will it proceed messages one by one? Meaning that some lucky guys will receive an answer within 5-15 secs and the rest of the crowd will be waiting and waiting up to one and a half minute?
  2. Will the workflow somehow “multiply” itself and peak the VPS resource usage? (risking to fail or put down the whole VPS)
  3. Will it be something in between? (like running in batches of 5)

Thanks a lot for your answers in advance!

Would say 2 is the closest.

It will always start directly with the execution. How exactly depends on the mode.

If n8n runs in “main” mode, then the execution starts directly in the main process. Obviously depends on the event loop. If that one is blocked, then nothing would happen unless it is unblocked like in any Node.js application. If it is not blocked (as it should be) then many things can run without a problem in parallel and n8n will take as much CPU and RAM as it needs and can get. A single instance n8n instance in “main” mode can normally take a lot of traffic. I would recommend using this one.

If n8n runs in “own” mode then a totally separate process gets started for each execution. So also multiple CPUs get used and if the execution crashes the process for some reason, it does not take whole n8n down. It comes however with the disadvantage that each process takes normally ~1 second to start and will need much more RAM (as almost the whole n8n code gets loaded into memory again for each process).

Hope that is helpful.

2 Likes

Thanks a lot!
So if I understand you correctly it doesn’t really depend on the starting node of the workflow (Webhook, Cron, Trigger, whatever). Actually, “Scaling n8n” documentation page covers this a bit, but I didn’t get the point previously.

And also thanks for mentioning the Node.js architecture, will check it too! It’s funny how at the end of the day no-code still requires understanding of the underlying software.

No, does not depend on the node starting the workflow.

Theoretically should it not be needed to understand the underlying architecture. Becomes only very important if issues arise to then tweak the setup for the specific needs to fix them. Generally should you be with simply setting it to “main” mode totally fine.

1 Like