N8n queue mode with workers pointing to multiple editors

Hello,

The title says it all. I would like to set a instance with n8n queue mode installed. The idea is to have multiple editors pointing to the same webhooks and workers to handle the requests. Is there a way to do that?

My first idea was to clone the n8n_editor service and replace the config with the new domain. However, I noticed that n8n_webhook and n8n_worker config sections have both a N8N_EDITOR_BASE_URL. If I use multiple editors, how should I point that?

Also, all 3 sections have DB_POSTGRESDB options to set the database. Is there a problem that the DB from the editor is different from the DB from the webhook and worker?

I’m using Portainer to do that.

Example of a config below.

version: “3.8”

services:
n8n_editor:
image: n8nio/n8n:latest
#command: start
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_PORT: 5432
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_DATABASE: n8n_fila
DB_POSTGRESDB_USER: postgres
DB_POSTGRESDB_PASSWORD: <SENHA_POSTGRES>
# criar chave Random key generator | ACTE Technology
N8N_ENCRYPTION_KEY: <SUA_KEY>
# hosts e URL
N8N_HOST: n8n.seu_dominio.com.br
N8N_EDITOR_BASE_URL: https://n8n.seu_dominio.com.br/
N8N_PROTOCOL: https
NODE_ENV: production
# webhooks
WEBHOOK_URL: https://webhook.n8n.seu_dominio.com.br/
# modo de execuçao para fila
EXECUTIONS_MODE: queue
# redis
QUEUE_BULL_REDIS_HOST: redis
QUEUE_BULL_REDIS_PORT: 6379
QUEUE_BULL_REDIS_DB: 2
# bibliotecas utilizadas
NODE_FUNCTION_ALLOW_EXTERNAL: moment,lodash,moment-with-locales
EXECUTIONS_DATA_PRUNE: ‘true’
EXECUTIONS_DATA_MAX_AGE: 336
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == manager
resources:
limits:
cpus: ‘0.3’
memory: 512M
labels:
- traefik.enable=true
- traefik.http.routers.n8n_editor.rule=Host(n8n.seu_dominio.com.br)
- traefik.http.routers.n8n_editor.service=n8n_editor
- traefik.http.routers.n8n_editor.entrypoints=websecure
- traefik.http.routers.n8n_editor.tls.certresolver=le
- traefik.http.routers.n8n_editor.tls=true
- traefik.http.services.n8n_editor.loadbalancer.server.port=5678
networks:
- traefik_public
- app_network

n8n_webhook:
image: n8nio/n8n:latest
command: webhook
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_PORT: 5432
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_DATABASE: n8n_fila
DB_POSTGRESDB_USER: postgres
DB_POSTGRESDB_PASSWORD: <SENHA_POSTGRES>
# criar chave https://acte.ltd/utils/randomkeygen
N8N_ENCRYPTION_KEY: <SUA_KEY>
# hosts e URL
N8N_HOST: n8n.seu_dominio.com.br
N8N_EDITOR_BASE_URL: https://n8n.seu_dominio.com.br/
N8N_PROTOCOL: https
NODE_ENV: production
# webhooks
WEBHOOK_URL: https://webhook.n8n.seu_dominio.com.br/
# modo de execuçao para fila
EXECUTIONS_MODE: queue
# redis
QUEUE_BULL_REDIS_HOST: redis
QUEUE_BULL_REDIS_PORT: 6379
QUEUE_BULL_REDIS_DB: 2
# bibliotecas utilizadas
NODE_FUNCTION_ALLOW_EXTERNAL: moment,lodash,moment-with-locales
EXECUTIONS_DATA_PRUNE: ‘true’
EXECUTIONS_DATA_MAX_AGE: 336
deploy:
mode: replicated
# pode criar replicas
replicas: 1
placement:
constraints:
- node.role == manager
resources:
limits:
cpus: ‘0.5’
memory: 320M
labels:
- traefik.enable=true
- traefik.http.routers.n8n_webhook.rule=Host(webhook.n8n.seu_dominio.com.br)
- traefik.http.routers.n8n_webhook.service=n8n_webhook
- traefik.http.routers.n8n_webhook.entrypoints=websecure
- traefik.http.routers.n8n_webhook.tls.certresolver=le
- traefik.http.routers.n8n_webhook.tls=true
- traefik.http.services.n8n_webhook.loadbalancer.server.port=5678
networks:
- traefik_public
- app_network

n8n_worker:
image: n8nio/n8n:latest
command: worker --concurrency=3
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_PORT: 5432
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_DATABASE: n8n_fila
DB_POSTGRESDB_USER: postgres
DB_POSTGRESDB_PASSWORD: <SENHA_POSTGRES>
# criar chave Random key generator | ACTE Technology
N8N_ENCRYPTION_KEY: <SUA_KEY>
# hosts e URL
N8N_HOST: n8n.seu_dominio.com.br
N8N_EDITOR_BASE_URL: https://n8n.seu_dominio.com.br/
N8N_PROTOCOL: https
NODE_ENV: production
# webhooks
WEBHOOK_URL: https://webhook.n8n.seu_dominio.com.br/
# modo de execuçao para fila
EXECUTIONS_MODE: queue
# redis
QUEUE_BULL_REDIS_HOST: redis
QUEUE_BULL_REDIS_PORT: 6379
QUEUE_BULL_REDIS_DB: 2
# bibliotecas utilizadas
NODE_FUNCTION_ALLOW_EXTERNAL: moment,lodash,moment-with-locales
EXECUTIONS_DATA_PRUNE: ‘true’
EXECUTIONS_DATA_MAX_AGE: 336
deploy:
mode: replicated
# pode criar replicas
replicas: 1
placement:
constraints:
- node.role == manager
resources:
limits:
cpus: ‘0.5’
memory: 384M
networks:
- traefik_public
- app_network

networks:
traefik_public:
external: true
app_network:
external: true

To simplify, webhooks and editors could be unique. But I need them pointing to the same workers. How to do that?

Hi @Matheus_Carneiro, this isn’t a supported setup as your workers will connect to a single database only and this would have to be the same database your main instance uses. So you can’t have one worker for multiple different main instances I am afraid.

Each of your main instances (the n8n_editor service in your config) would require a separate worker pool.

1 Like

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