Differences and uses - Workers / Concurrencies

Hi !

I don’t understand completely the difference between workers and concurrencies in each worker. So here are my list of questions :

  • Can 1 worker with multiple concurrencies use several CPU Threads ?
  • Can multiple workers with 1 concurrency use several CPU Threads ?
  • What’s the point on having several workers with several concurrencies for each of them ?
  • What’s the most optimized way to use workers and concurrencies in order to fully use 32 threads ?
  • Can a worker or concurrency start another workflow if the one currently running is waiting for something ?

Information on your n8n setup

  • **n8n version:**0.182.1
  • **Database (default: SQLite):**PostgreSQL
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):**Unknown
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):**Docker
  • **Operating system:**Debian

@krynble Do you have any thoughts on this one?

Hi,

Forgot to mention that I entirely read the following documentation : Configuring queue mode | n8n Docs

I understand that workers allow multiple webhooks tu run simultaneously, and concurrencies allow multiple workflows to run simultaneously. But I don’t understand the difference, and which I should use (might be both).

Currently, we have several webhooks, each starting multiple workflows (like 3 workflows per webhook in average). We’re sometimes having performances issues, and I’d like to know how I can optimize our instance the best.

Hey @Gwendal,

There are 2 types of wokers a normal worker that you can set the concurrency to and webhook workers which are workers that just handle webhooks and I believe they drop the data to the database for a worker to pick up so you would be best to have a mix of the 2 so that you are not sending all of your webhook traffic to your main n8n instance.

Optimizing an instance all depends on what you are using and there is no magic answer to it there will be some trial and error with various settings to find out what works for your environment and your load.

Below are some notes on your original questions from another team member that may also help.

    Can 1 worker with multiple concurrencies use several CPU Threads ?

worker concurrency determines how many parallel executions a worker can have at any time.
But, all these parallel executions are still running in a single threaded application.
So, if you have a lot of I/O, then these executions run more or less in parallel, but if you have a code node with a lot of slow synchronous code, then a single execution can block the entire thread until it’s finished.

    Can multiple workers with 1 concurrency use several CPU Threads ?

Yes. each worker gets it’s own process. So, you can use a multi-core CPU more effectively.

    What’s the point on having several workers with several concurrencies for each of them ?

Multiple workers help by making the processing multi-threaded. But, You still need concurrency within a worker to utilize the resources better when a lot of time is spend on I/O. If you have workers with a concurrency of 1, you end up with a system that does nothing while it’s making http requests, or reading/writing to the filesystem.

    What’s the most optimized way to use workers and concurrencies in order to fully use 32 threads ?

This quite a lot depends on your workload, and might need customization by you.
n8n workers default concurrency to 10 by default. But if you have a lot of I/O in your executions, it might make sense to increase this value, until you notice executions slowing down. I’ve seen setups with a concurrency of 30.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.