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:
Here are my questions
- As soon as all instances use same DB will not they stole each other events?
- If I update the workflow in one instance will it be propagated to other? because they share same DB
- Do you see other concerns?
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.
Thank you @jan for your response, It’s just want I need .
Looks like in my case n8n +K8 is suitable solution !
Great to hear that it was helpful!
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:
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