Building High Availability for MySQL HeatWave Using MySQL Router
Table of Contents
1. Introduction
Modern applications demand database services that remain available during maintenance events, infrastructure failures, and unexpected outages. While MySQL HeatWave on Oracle Cloud Infrastructure (OCI) provides built-in High Availability through managed replication and automated failover, applications still need a reliable, transparent way to connect to the correct database instance at all times.
This is where MySQL Router becomes a critical component. MySQL Router acts as an intelligent, lightweight database proxy that provides a stable connection endpoint for applications while automatically directing traffic to the appropriate MySQL HeatWave instance — whether it is the current primary, a read replica, or a newly promoted node after failover.
In this article, we will explore how to architect a highly available MySQL HeatWave deployment on OCI using MySQL Router, complete with reference architecture diagrams, configuration examples, failover testing procedures, and performance comparisons.
2. Understanding MySQL HeatWave High Availability
MySQL HeatWave is Oracle's fully managed cloud database service that unifies OLTP, analytics, machine learning, GenAI, and Lakehouse capabilities in a single platform. The service includes enterprise-grade high availability mechanisms designed to minimize downtime and automate failover operations.
2.1 HA Component Architecture
A typical HeatWave HA deployment on OCI consists of:
- Primary DB System — Handles all write operations (INSERT, UPDATE, DELETE)
- Secondary DB System(s) — One or more read-only replicas for failover and read scaling
- Automatic Replication — Synchronous or near-synchronous replication between primary and secondaries
- Automated Failover — Oracle's control plane automatically promotes a healthy secondary when the primary becomes unavailable
- HeatWave Cluster (optional) — In-memory analytics cluster attached to the DB system for analytical workloads
2.2 Failover Behavior
When a failure occurs on the primary instance, MySQL HeatWave's control plane automatically detects the outage and promotes the most up-to-date secondary instance to become the new primary. This process typically completes within 30-60 seconds, depending on the configuration and replication lag.
3. Why MySQL Router?
Applications traditionally connect directly to a database endpoint. During failover events, this creates several challenges:
- Applications may need reconfiguration to point to the new primary
- Connection strings may need updating across multiple services
- Existing connections can fail, causing errors and data loss
- Manual intervention may be required, increasing recovery time
MySQL Router solves these challenges by acting as a transparent routing layer between applications and the database backend.
3.1 Key Benefits
- Single connection endpoint — Applications connect to Router, never directly to database nodes
- Automatic routing — Router tracks topology and directs traffic to the active primary
- Read/Write splitting — Separate ports for write (6446) and read (6447) traffic
- Zero-downtime failover — Applications use the same connection endpoint through failover events
- Lightweight — Minimal resource footprint, can be deployed alongside application servers
- Metadata-driven — Router uses InnoDB Cluster metadata to track topology changes in real time
4. OCI Reference Architecture
The following architecture diagram illustrates a production-grade deployment of MySQL Router with MySQL HeatWave on OCI, including networking, load balancing, and multi-AZ placement.
- MySQL Router instances are deployed inprivate subnetsalongside application servers for minimal latency
- HeatWave DB systems are distributed across3 Availability Domains(AD-1, AD-2, AD-3) for maximum fault tolerance
- AnOCI Load Balancersits in front of Router instances for TLS termination and health-based routing
- ABastion Instanceprovides secure SSH access for administration
- All database traffic flows throughprivate networking— no public endpoints are exposed for HeatWave
5. HeatWave HA Deployment Walkthrough
5.1 Prerequisites
- OCI tenancy with appropriate compartment and IAM policies
- VCN with public and private subnets across 3 ADs
- MySQL HeatWave DB System (standalone) with automatic backups enabled
- All database tables must have primary keys
- No HeatWave Cluster attached (must be detached before enabling HA)
- No active bulk ingestion jobs running
5.2 Enabling HA via OCI Console
- Navigate to MySQL HeatWave → DB Systems in the OCI Console
- Select your DB System and click Enable High Availability
- Confirm the operation — the system enters
UPDATINGstate - Secondary instances are automatically cloned from the primary
- Once complete, the DB System shows HA: Enabled with status Active
5.3 Enabling HA via OCI CLI
5.4 Verifying HA Status
5.5 Deploying MySQL Router
6. MySQL Router Configuration
6.1 Bootstrap Mode (InnoDB Cluster)
If your HeatWave deployment supports InnoDB Cluster metadata, you can bootstrap Router for automatic topology discovery:
6.2 Static Configuration (HeatWave Managed HA)
For HeatWave managed HA deployments where InnoDB Cluster metadata is not available, configure Router in static mode:
6.3 Starting and Enabling Router
6.4 Verifying Router Connectivity
7. Read/Write Splitting Configuration
7.1 How It Works
MySQL Router provides read/write splitting through separate TCP ports — it does not parse SQL queries to determine read vs. write. Instead, the application directs traffic to the appropriate port:
- Port 6446 (Read/Write) → Always routes to the PRIMARY instance
- Port 6447 (Read-Only) → Routes to SECONDARY instances using round-robin load balancing
7.2 Application Integration (Python Example)
7.3 Application Integration (Node.js Example)
8. Failover Test Walkthrough
8.1 Test Topology
8.2 Simulated Failover Test
The following terminal session demonstrates a controlled failover test. We simulate a primary node failure and observe how MySQL Router and HeatWave respond.
9. Performance: With vs Without Read/Write Splitting
9.1 Test Methodology
We conducted load testing using sysbench with the OLTP Read/Write workload against a 3-node HeatWave HA cluster (1 Primary + 2 Secondaries). Two configurations were compared:
- Without R/W Splitting — All traffic (reads and writes) routed through port 6446 to the primary
- With R/W Splitting — Writes via port 6446 (primary), reads via port 6447 (secondaries, round-robin)
- HeatWave: 3× VM.Standard.E4.Flex (4 OCPUs, 64GB RAM)
- MySQL Router: 2× VM.Standard.E4.Flex (2 OCPUs, 16GB RAM)
- Table size: 5 million rows, 100MB dataset
- sysbench OLTP RW mix: 15% writes, 85% reads
- Test duration: 30 minutes per run, 5-minute warmup
9.2 Results Summary
9.3 Performance Comparison Visualization
9.4 Key Takeaways
- Throughput increased by 130% — Read traffic offloaded to secondaries, freeing the primary for writes
- Read latency reduced by 71.6% — SELECT queries served from replicas with less contention
- Primary CPU dropped from 78% to 42% — Significant headroom for write operations and replication
- Connection errors reduced by 95.7% — Primary no longer overwhelmed during peak read loads
- Write latency impact is negligible (+5.8%) — Writes continue to go directly to primary with minimal overhead
10. Best Practices
10.1 Deploy Multiple Router Instances
Avoid introducing a new single point of failure. Deploy at least 2 MySQL Router instances behind an OCI Load Balancer with health checks. If one Router fails, the Load Balancer automatically routes traffic to the healthy instance.
10.2 Use Private Networking
Keep all Router-to-HeatWave communication within private subnets. Never expose MySQL Router or HeatWave endpoints to the public internet. Use a Bastion host for administrative access.
10.3 Monitor Failover Events
Set up monitoring for the following metrics using OCI Monitoring and MySQL Enterprise Monitor:
- Replication health and lag between primary and secondaries
- Router availability and connection counts per port
- Database failover events and promotion times
- Connection latency (p50, p95, p99) through Router
- Primary CPU, memory, and I/O utilization
10.4 Test Failover Regularly
Conduct monthly failover drills in a staging environment to validate:
- Application behavior during and after failover
- Recovery times meet your RTO requirements
- Connection handling — verify apps reconnect automatically
- Monitoring alerts fire correctly
10.5 Use HeatWave HA Configurations
Production environments should always use HA-enabled configurations (HA-Basic or HA-Advanced) to benefit from Oracle-managed failover, automated backup, and recovery capabilities. Never run production workloads on standalone DB Systems without HA.
10.6 Application-Level Resilience
11. Conclusion
MySQL HeatWave provides enterprise-grade High Availability capabilities through managed replication and automated failover. When combined with MySQL Router as the application access layer, organizations can build a resilient, cloud-native database platform that delivers:
- Zero-downtime failover — Applications connect to a stable Router endpoint that automatically redirects to the new primary
- 2x throughput — Read/write splitting offloads read traffic to secondaries, dramatically improving performance
- Reduced operational complexity — No manual connection string updates or application reconfiguration during failover
- Multi-AZ resilience — HeatWave instances distributed across OCI Availability Domains with Router instances behind a Load Balancer
By introducing MySQL Router as the transparent routing layer, you abstract database topology changes from your applications, automate failover handling, and create a production-ready HA architecture on MySQL HeatWave — all within Oracle Cloud Infrastructure.
Comments