N8n Multi-server configuration - K8s Service as Load Balancer

Hi everyone,
Thanks to my previous post I have a diff ready to implement multi-main on my local k8s n8n deployment.

One thing that the documentation says is that:

All main processes are running behind a load balancer with session persistence (sticky sessions) enabled.

I currently have a k8s service that is the main interface to the n8n (single) main instance in queue mode.
Is it enough implementing sticky sessions on the service?
Do I need a different load balancer for multi-main?

It would look something like:

apiVersion: v1
kind: Service
metadata:
  name: n8n
  namespace: n8n
spec:
  selector:
    app.kubernetes.io/name: n8n
  type: ClusterIP
  ports:
    - name: http
      protocol: TCP
      port: 5678
      targetPort: 5678
  sessionAffinity: ClientIP
  sessionAffinityConfig:
    clientIP:
      timeoutSeconds: 43200    # stick for 12 hours

Information on your n8n setup

  • n8n version:docker.io/n8nio/n8n:1.37.2
  • Database (default: SQLite): PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docket
  • Operating system: Ubuntu

The sessionAffinity: ClientIP setting in your current Kubernetes Service definition is generally sufficient for small to medium-scale usage.

However, for a true production environment and high availability, a cookie-based sticky session with an NGINX or similar load balancer is preferred.

1 Like

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