Set Up High Availability
High availability (HA) ensures your applications remain operational during hardware failures, network outages, or maintenance windows. CloudNexus provides native tools to deploy active-active or active-standby architectures across multiple regions with automated failover, zero-downtime updates, and consistent global latency.
This guide walks you through provisioning a production-ready HA setup using the CloudNexus CLI, managed load balancers, replicated databases, and intelligent health checking.
Prerequisites
- CloudNexus account with Professional or Enterprise tier
- CloudNexus CLI installed and authenticated:
cx-cli auth login - Access to at least two geographic regions
- Application containerized (Docker) or compatible with CloudNexus App Server
Target Architecture
The recommended HA topology uses a global load balancer distributing traffic to regional clusters. Each region runs independently synchronized instances, with an asynchronous primary-replica database setup for low-latency reads and crash-safe writes.
Step-by-Step Setup
Provision Multi-Region Nodes
Create identical compute clusters across your target regions. Use the cx-cli to define node pools with identical resource allocations.
# Create regional node pools cx-cli cluster create --region us-east-1 --name ha-cluster-us --nodes 3 cx-cli cluster create --region eu-west-1 --name ha-cluster-eu --nodes 3 cx-cli cluster create --region ap-tokyo-1 --name ha-cluster-ap --nodes 2 # Verify cluster status cx-cli cluster list --status running
Configure Global Load Balancer
Deploy an anycast load balancer that routes traffic based on latency, availability, and custom health probes. Enable sticky sessions if your application requires state persistence.
# lb-config.yaml loadbalancer: name: global-ha-lb type: anycast algorithm: least-connections sticky_session: true tls: cert_arn: arn:cx:acm:us-east-1:cert-48291 targets: - cluster: ha-cluster-us weight: 40 - cluster: ha-cluster-eu weight: 35 - cluster: ha-cluster-ap weight: 25
--health-path /healthz when applying the config to ensure the LB only routes to healthy nodes.
cx-cli lb create --config lb-config.yaml --health-path /healthz
Set Up Managed Database Replication
Create a primary database instance in your main region and configure asynchronous read replicas in secondary regions. This minimizes write latency while providing failover-ready data.
# Create primary PostgreSQL cluster cx-cli db create --engine postgresql --tier ha-primary --region us-east-1 --name app-db-primary # Add cross-region async replicas cx-cli db replica create --source app-db-primary --region eu-west-1 --mode async cx-cli db replica create --source app-db-primary --region ap-tokyo-1 --mode async
Enable Automated Failover & Health Monitoring
Activate the CloudNexus Health Gateway to continuously probe all endpoints. Configure automatic promotion rules so replicas become primary within seconds of a region failure.
cx-cli failover configure --cluster-group ha-clusters \\ --health-interval 5s \\ --promote-on region-down,health-check-fail \\ --dns-failover enabled
Verification & Testing
Run the following commands to validate your HA setup before going live:
- Health Check Validation:
cx-cli health run --all --verbose - Failover Simulation:
cx-cli failover simulate --target us-east-1 - Latency Map:
cx-cli lb trace --global
Expected output shows all regions in HEALTHY state, with failover time < 3.2s and zero packet loss during region simulation.
Best Practices
- Idempotent Deployments: Ensure your app handles duplicate requests gracefully during failover windows.
- Connection Pooling: Use PgBouncer or ProxySQL to manage database connections across regions.
- Backup Strategy: Enable cross-region automated snapshots with
--retention 30d. - Cost Optimization: Use traffic shaping to route non-critical workloads to cheaper regions during peak hours.
- Monitoring: Integrate with CloudNexus Metrics API or Prometheus for real-time SLA tracking.