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.

What must be shared
- JWT secret —
JWT_SECRETmust 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
- Open Settings → Clustering and enable clustering.
- Add each peer node (name, IP, gateway port 8080) and check connectivity (UP/DOWN).
- 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.