Scaling n8n in Kubernetes

Hello Community,
I am wondering if it’s good idea to use Kubernetes for scaling n8n workflows.
I want to have few replicas of same n8n instance that will share same DB,
that will expose same webhook to trigger the workflow, in front of them will use K8 LoadBalancer, so every time the webhook will be triggered in one instance ex:
Selection_014

Here are my questions

  1. As soon as all instances use same DB will not they stole each other events?
  2. If I update the workflow in one instance will it be propagated to other? because they share same DB
  3. Do you see other concerns?

Best Regards,
Vitalie.

1 Like

Yes, that would work fine. But be aware that it will only work correctly for Webhook-Nodes. For every other Trigger-Node that would cause problems.

Apart from that you just have to be aware that it will not work when running workflows manually. As manual executions get only registered on one instance, so the chance that the test-webhook call ends up at the correct instance would be 33%. So would actually be best to have one for production (which has the load balancer and you start multiple replicas) and one for testing (which does not have any replicas) and you use only for development and to edit workflows. All of them have to however share the same database.

Hope that makes sense.

1 Like

Thank you @jan for your response, It’s just want I need :+1: .
Looks like in my case n8n +K8 is suitable solution :slight_smile: !

1 Like

Great to hear that it was helpful!

Have fun!

1 Like

Just FYI. There is currently an open PR that adds a job-queue to n8n. It would make it much simpler to scale n8n. Is still in alpha but you can find it here if you want to test and give feedback:
https://github.com/n8n-io/n8n/pull/1294

Will this be implemented?

It is already implemented (see PR above) but it did not get merged yet. Still reviewing and testing it internally. Will be merged probably soon

1 Like