Set Up High Availability

πŸ•’ 15 min read πŸ”„ Updated: Oct 24, 2025 🏷️ Architecture

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.

🌐Global LB
πŸ”Health Checks
πŸ”’SSL/TLS
πŸ‡ΊπŸ‡ΈUS-East Cluster
πŸ‡ͺπŸ‡ΊEU-West Cluster
πŸ‡―πŸ‡΅AP-Tokyo Cluster
πŸ—„οΈPrimary DB
πŸ”„Async Replicas
πŸ“ŠMetrics

Step-by-Step Setup

Step 1

Provision Multi-Region Nodes

Create identical compute clusters across your target regions. Use the cx-cli to define node pools with identical resource allocations.

bash
# 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
Step 2

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.

yaml
# 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
πŸ’‘
Tip Use --health-path /healthz when applying the config to ensure the LB only routes to healthy nodes.
bash
cx-cli lb create --config lb-config.yaml --health-path /healthz
Step 3

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.

bash
# 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
Step 4

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.

bash
cx-cli failover configure --cluster-group ha-clusters \\
  --health-interval 5s \\
  --promote-on region-down,health-check-fail \\
  --dns-failover enabled
⚠️
Important DNS-based failover depends on TTL settings. Ensure your DNS provider is set to ≀60 seconds for rapid propagation during outages.

Verification & Testing

Run the following commands to validate your HA setup before going live:

  1. Health Check Validation: cx-cli health run --all --verbose
  2. Failover Simulation: cx-cli failover simulate --target us-east-1
  3. 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.
← Auto Scaling Guide Database Clusters β†’