Many applications still depend on a single virtual machine to run their databases, business services, or legacy workloads. These applications may not be designed to run across multiple instances, and moving them to a distributed architecture can require significant development and testing.
The problem becomes more serious when a virtual machine runs in a zone that experiences an infrastructure failure. Even if the application and its data are still available elsewhere, the workload cannot continue until the VM and its storage are recovered.
Google Cloud addresses this scenario with Compute Engine high availability controllers. This feature helps move a stateful VM from a primary zone to a secondary zone within the same region. It coordinates disk attachment, VM startup, and network traffic redirection without requiring administrators to manually rebuild the entire environment.
In this article, we'll explore how high availability controllers work, how to configure them, how to trigger a planned failover, and what developers and cloud administrators should consider before using them.
What Are High Availability Controllers?
A high availability controller is a Compute Engine resource that manages failover for an existing virtual machine across two zones in the same Google Cloud region.
The controller pairs with a running VM in the primary zone and maintains a capacity guarantee for starting that VM in a secondary zone. If the primary zone experiences a qualifying disruption, the controller can start the workload in the secondary zone and redirect network traffic to it.
This is particularly useful for stateful or legacy applications that run on a single VM and cannot easily be redesigned to run across multiple instances.
For example, imagine a business application running on a VM in the us-central1-a zone. Its boot disk contains the operating system, while a separate data disk stores application files and database information.
If the primary zone becomes unavailable, the application cannot continue running from that VM. A high availability controller can use the regional disk replicas to start the same workload in us-central1-b.
The controller handles the infrastructure-level failover while the application retains its existing configuration.
The feature is currently in Preview, so organizations should review the applicable Pre-GA terms and limitations before using it for critical workloads.
How High Availability Controllers Work
A high availability controller uses three important components:
- A primary VM running in the original zone.
- Regional Persistent Disk or Hyperdisk Balanced High Availability volumes replicated across two zones.
- A secondary zone with guaranteed capacity for starting the VM during failover.
The controller monitors infrastructure health and manages the transition between the two zones.
Normal operating stage
During normal operation, the VM runs in the primary zone. Its regional disks maintain synchronous replicas across the primary and secondary zones.
For example:
Google Cloud Region: us-central1
Primary Zone Secondary Zone
us-central1-a us-central1-b
| |
v v
+-------------+ +-------------+
| Running VM | | Disk Replica|
| | | |
+-------------+ +-------------+
| ^
+------ Synchronous --------+
Replication
The primary VM performs application processing and disk operations. The secondary zone maintains the replicated disk data and the capacity guarantee needed for a future failover.
The secondary zone does not continuously run an identical active VM for this controller model. Instead, the controller starts the VM there when failover is required.
Failover stage
When a qualifying disruption occurs, or an administrator manually initiates a failover, the controller coordinates the transition.
The process generally follows these steps:
- The controller initiates the failover and force-attaches the regional disks in the secondary zone. This prevents further writes from the original primary VM.
- Compute Engine starts the VM in the secondary zone using the same VM name and machine configuration.
- The controller redirects network traffic to the new active VM.
- The original VM is stopped and its disks are detached when the original zone is accessible.
After the failover completes, the secondary zone becomes the new primary zone. The original zone becomes the new secondary zone once it recovers.
This design helps protect against data loss on supported disks because regional disk replication is synchronous. However, data that exists only in VM memory or unflushed operating system buffers can still be lost.
Post-failover stage
After the VM starts in the secondary zone, the application should resume its normal operations.
The controller maintains the new primary and secondary zone configuration and restores the capacity guarantee in the recovered zone.
This means the same controller can continue protecting the workload after a failover rather than requiring administrators to create a completely new configuration.
When Should You Use High Availability Controllers?
High availability controllers are intended for workloads that run on a single VM and need protection against zonal infrastructure disruptions.
Common examples include:
- Legacy business applications that cannot easily run on multiple instances.
- Databases running on a single Compute Engine VM.
- Stateful services that depend on local VM configuration and attached persistent disks.
- Applications that require a consistent VM identity and configuration during recovery.
- Enterprise workloads that need a planned way to move between zones.
However, high availability controllers are not a general replacement for regional managed instance groups.
A regional managed instance group is generally more appropriate for stateless applications or distributed workloads that can run across multiple VMs. A high availability controller is designed for a single-VM workload that needs its existing stateful configuration protected.
Requirements Before Creating a Controller
Before creating a high availability controller, review the VM, storage, networking, and capacity requirements.
Supported regional disks
All disks attached to the managed VM, including its boot disk and data disks, must use supported regional storage.
Supported options include:
- Regional Standard Persistent Disk.
- Regional Balanced Persistent Disk.
- Hyperdisk Balanced High Availability.
These disk types replicate data across two zones in the same region.
If your VM currently uses supported zonal disks, you can convert them to regional disks during controller creation. The conversion stops and restarts the VM, so plan a maintenance window.
Local SSD disks are not supported because their data is not replicated across zones for this failover model.
Some other disk configurations also require migration before the controller can be created. For example, automatic conversion does not support customer-supplied encryption keys (CSEKs), Confidential-mode Hyperdisk Balanced volumes, or regional SSD Persistent Disk volumes.
Supported VM configuration
The VM must use a supported machine series and the standard provisioning model.
High availability controllers do not support Flex-start VMs, Spot VMs, or reservation-bound provisioning models.
The primary and secondary zones must belong to the same region. For example, a VM in us-central1-a can use us-central1-b as its secondary zone, but it cannot use a zone in europe-west1.
Application startup
The application must be configured to start automatically when the VM starts.
For Linux workloads, you can use systemd services or startup scripts. Windows workloads can use Windows services or other startup mechanisms.
For example, a Linux application can use a systemd unit:
[Unit]
Description=Business Application
After=network.target
[Service]
Type=simple
WorkingDirectory=/opt/business-app
ExecStart=/usr/bin/dotnet /opt/business-app/BusinessApp.dll
Restart=always
RestartSec=5
User=appuser
[Install]
WantedBy=multi-user.target
Save the configuration as a service file, such as /etc/systemd/system/business-app.service, and enable it:
sudo systemctl daemon-reload
sudo systemctl enable business-app
sudo systemctl start business-app
This ensures that the application starts automatically after the VM boots in either zone.
If the application uses separate data disks, configure the operating system to mount them automatically during startup. Test the mount configuration before enabling failover.
Creating a High Availability Controller
You can create a controller through the Google Cloud console or the Google Cloud CLI.
The following example uses an existing VM named business-vm in the us-central1-a zone. The secondary zone is us-central1-b.
Prepare the environment
First, authenticate with the Google Cloud CLI and select the correct project.
gcloud auth login
gcloud config set project YOUR_PROJECT_ID
gcloud components update
Make sure the VM is running and that its attached disks meet the controller requirements.
You also need the appropriate Compute Engine permissions. The predefined Compute Instance Admin (v1) role includes the permissions required for creating a controller. Shared VPC deployments can also require the Compute Network User role in the host project.
Create the controller
Use the preview command to create a controller with automatic failover initiation:
gcloud preview compute ha-controllers create business-ha-controller \
--region=us-central1 \
--instance-name=business-vm \
--failover-initiation=automatic \
--zone-configuration=zone=us-central1-a \
--zone-configuration=zone=us-central1-b \
--network-auto-configuration=stack-type=IPV4_ONLY
Replace the project, VM name, region, and zones with values from your environment.
The example uses automatic network configuration and an IPv4-only stack. If your environment uses IPv4 and IPv6, select the appropriate stack configuration supported by the CLI.
If the VM has supported zonal disks that you want Compute Engine to convert during controller creation, add the following flag:
--migrate-disks-to-regional
This conversion stops the VM, creates regional disk replicas, updates disk attachments, and restarts the VM. It can introduce downtime, so do not run it during an unplanned production event.
For a deployment that uses reservations or sole-tenant nodes, configure the corresponding zone settings instead of relying on the default on-demand capacity behavior.
Configure application traffic
After creating the controller, clients should connect through the controller's internal forwarding rule address instead of connecting directly to the VM's original network interface address.
The controller can manage network configuration automatically. Alternatively, you can provide an existing regional backend service for an internal passthrough Network Load Balancer.
For the custom backend service option, the backend service must have its HA policy enabled and must not already have backends attached. The controller manages the zonal network endpoint groups and updates the backend service during failover.
If you use static internal IP addresses for the VM interfaces, reserve addresses in both zones. This prevents another resource from claiming the secondary address while the VM is running in the primary zone.
The exact networking approach depends on the application and existing VPC architecture. Test client connectivity through the forwarding rule before considering the deployment complete.
Testing a Planned Failover
A successful deployment should be tested before it is needed during an actual outage.
A manual failover is useful for checking whether the application starts correctly in the secondary zone and whether clients can reconnect.
Before testing, pause the workload where possible. Make sure important application data is flushed to disk and that clients can retry dropped connections.
You can initiate a failover with the following command:
gcloud preview compute ha-controllers failover \
business-ha-controller \
--region=us-central1
The command triggers a failover from the current primary zone to the secondary zone.
During this process, active network connections to the VM are dropped. Applications that maintain long-running connections must be prepared to reconnect.
After the operation, verify that:
- The VM is running in the new primary zone.
- Regional disks are attached correctly.
- The application services have started.
- The forwarding rule sends traffic to the active VM.
- Clients can reconnect successfully.
- Application logs do not show storage or startup errors.
A planned failover is also useful for maintenance. For example, an administrator can move a workload to the secondary zone before scheduled work in the primary zone.
Automatic and Manual Failover
Google Cloud provides two failover initiation modes.
Area | Automatic | Manual-only |
|---|
Trigger | Qualifying infrastructure disruption or administrator request | Administrator request |
Zonal outage response | Automatically initiates failover when supported conditions are detected | Requires manual action |
Maintenance testing | Can be triggered manually | Can be triggered manually |
Operational involvement | Less intervention during qualifying events | More administrator involvement |
Suitable for | Workloads requiring automated infrastructure recovery | Workloads requiring controlled failover decisions |
Automatic failover is useful when the application must recover without waiting for an administrator. Manual-only failover can be useful when teams want to control exactly when the workload moves between zones.
The automatic mode does not detect every type of application failure. It focuses on infrastructure and zonal health. An application crash, operating system kernel panic, or regional outage is not automatically handled by the controller.
Google Cloud also notes that a complete zone outage might prevent automatic failover from starting. In that situation, an administrator might need to trigger a manual failover.
Monitoring and Troubleshooting
A high availability controller should be treated as an operational component of the application architecture.
Compute Engine writes audit logs when a controller changes state, detects an unhealthy VM, or starts or completes a failover. These logs help administrators understand what happened during a recovery operation.
You can use Cloud Logging to review controller-related activity and configure log-based alerts for important events.
Common problems include the following.
Regional disk requirement errors
If the VM has unsupported zonal or local disks attached, controller creation can fail.
Review every attached disk, including the boot disk. Convert supported zonal disks to regional disks or migrate unsupported storage to a supported disk type before creating the controller.
Local SSD disks are attached
Local SSD data is not replicated across zones for this feature.
Remove the Local SSD dependency or redesign the workload to use supported regional storage before creating the controller.
Secondary VM name conflict
The controller starts the VM in the secondary zone using the same name. If another VM already uses that name in the secondary zone, the failover configuration can fail.
Check for duplicate VM names and remove or rename conflicting resources before creating the controller.
Global DNS configuration
High availability controllers require zonal DNS. Projects or VMs using global DNS need to migrate to zonal DNS before using the feature.
Application does not start after failover
The controller manages infrastructure recovery, but it does not guarantee that every application process will start successfully.
Check systemd services, Windows services, startup scripts, disk mount settings, application dependencies, and logs from the new primary zone.
Backup and restore problems
Traditional VM backup plans can have limitations for controller-managed workloads because a backup plan might target a specific zone. After failover, the VM and its disks can be associated with a different zone.
For these workloads, use supported regional disk backup methods, such as backup vaults or disk snapshots. When restoring a disk, restore it to a regional disk replicated across the controller's two zones, then follow the documented procedure to replace the disk on the managed VM.
High Availability Controllers vs. Regional Managed Instance Groups
Both high availability controllers and regional managed instance groups help improve availability, but they solve different problems.
Feature | High availability controller | Regional managed instance group |
|---|
Primary use | Protect a stateful single-VM workload | Run multiple VM instances across zones |
Workload model | Single VM with regional disks | Multiple instances |
Data handling | Synchronous regional disk replication | Depends on application-level data replication and workload design |
Failover | Moves the managed VM to another zone | Maintains or recreates instances according to MIG configuration |
Scaling | Not intended for horizontal scaling | Supports instance group scaling |
Application changes | Often suitable for existing single-VM applications | Applications must support the multi-instance design |
Best suited for | Stateful and legacy workloads | Stateless or distributed workloads |
A regional managed instance group is a better fit when the application can run on multiple instances and manage its own shared or replicated data.
A high availability controller is a better fit when the application depends on a single VM and needs an infrastructure-level way to recover in another zone.
Best Practices for Production Workloads
Before relying on high availability controllers in production, consider the following practices:
- Use supported regional disks for every attached volume. Do not leave an important application data disk outside the regional replication design.
- Configure application startup services and test them after a normal VM restart.
- Use static internal IP addresses where predictable network identity is important, and reserve the required addresses in both zones.
- Configure clients to connect through the controller-managed forwarding rule rather than the VM's original NIC address.
- Make applications resilient to dropped connections. Clients should retry requests safely and handle temporary connection failures.
- Flush important application data to disk. Regional replication protects committed disk writes, not data that exists only in memory.
- Test manual failovers regularly in a controlled environment.
- Monitor controller audit logs and create alerts for failover events and unexpected state changes.
- Maintain independent backups. Synchronous replication protects against certain zonal failures, but it does not replace backups for accidental deletion, corruption, or application-level data problems.
- Document the manual recovery procedure in case an automatic failover does not start.
Advantages and Limitations
Advantages
- Automates zone-to-zone failover for supported single-VM workloads.
- Uses synchronous regional disk replication to protect committed disk data.
- Maintains a capacity guarantee in the secondary zone.
- Redirects network traffic after the VM starts in the new zone.
- Supports automatic and manual failover modes.
- Helps protect legacy applications without requiring an immediate multi-VM redesign.
Limitations
- The feature is currently in Preview.
- It supports a single-VM workload rather than a multi-instance application architecture.
- Both zones must be in the same region.
- Supported regional disks are required; Local SSD disks are not supported.
- Application memory and unflushed operating system buffers are not replicated.
- It does not detect application crashes or protect against regional outages.
- Active network connections drop during failover and must be re-established.
- A complete zonal outage might require manual failover if automatic initiation does not occur.
Summary
Google Cloud high availability controllers provide a practical way to protect stateful Compute Engine workloads that run on a single VM. They coordinate regional disk attachment, VM startup, and network traffic redirection when moving a workload from a primary zone to a secondary zone.
The feature is particularly useful for legacy applications and services that cannot easily be redesigned for multiple VM instances. By combining regional Persistent Disk or Hyperdisk Balanced High Availability volumes with a secondary-zone capacity guarantee, organizations can reduce recovery time and protect committed disk data during supported infrastructure disruptions.
However, high availability controllers do not replace application-level resilience, backups, or regional disaster recovery. Applications must still handle dropped connections, start correctly after a VM restart, and flush important data to persistent storage.
Before adopting the feature, validate the disk configuration, network setup, capacity requirements, and recovery process. A planned failover test is one of the best ways to confirm that the entire application—not just the VM—can recover successfully.
Join the conversation! Your thoughts help the community grow.