Developer Guide / Clustering & High Availability

Clustering & High Availability

Run multiple portal nodes behind a load balancer.

Magic Varsh scales horizontally: because services and JWT auth are stateless, identical full stacks run on multiple machines, all pointing at one shared PostgreSQL, with a load balancer in front and automatic failover.

Cluster configuration under Settings → Cluster.
Cluster configuration under Settings → Cluster.

What must be shared

  • JWT secretJWT_SECRET must be identical on every node (min 32 chars), or tokens fail to validate after failover.
  • Database — one shared PostgreSQL 16 instance reached by all nodes (DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASS).
  • Files / assets — shared via NFS, S3/MinIO, or stored as BLOBs in PostgreSQL.

Setup

  1. Open Settings → Clustering and enable clustering.
  2. Add each peer node (name, IP, gateway port 8080) and check connectivity (UP/DOWN).
  3. Generate the load-balancer config.

The generated Nginx upstream uses least_conn across the nodes with proxy_next_upstream error timeout http_502 http_503 http_504 for automatic retry on the next healthy node. Node health is checked at /actuator/health, and each node runs Flyway on startup safely because Flyway takes a PostgreSQL lock so only one node applies each migration.