Test a primary instance for high availability

To help ensure high availability (HA), every AlloyDB primary instance has both an active node and a standby node, located in two different zones. If the active node becomes unavailable for any reason, then AlloyDB automatically promotes the standby node to become the new active node.

You can test this automatic HA feature by using fault injection to abruptly force your primary instance's active node offline. AlloyDB then activates the emergency HA procedure that checks the primary instance's health and then reassigns the standby node into the active-node role.

Fault injection also initiates a long-running operation that brings the former active node back online after a brief interval. That node becomes the new standby node of the primary instance.

For a faster method of swapping the active and standby roles of your primary instance's nodes, see Fail over a primary instance manually.

Before you begin

  • The Google Cloud project you are using must have been enabled to access AlloyDB.
  • You must have one of these IAM roles in the Google Cloud project you are using:
    • roles/alloydb.admin (the AlloyDB Admin predefined IAM role)
    • roles/owner (the Owner basic IAM role)
    • roles/editor (the Editor basic IAM role)

    If you don't have any of these roles, contact your Organization Administrator to request access.

Simulate an outage with a fault injection

To test your primary instance's HA resiliency by abruptly shutting down its active node, use the gcloud alloydb instances inject-fault command. After a long-running operation completes, AlloyDB reinstates the node.

gcloud alloydb instances inject-fault INSTANCE_ID \
    --fault-type=stop-vm \
    --region=REGION_ID \
    --cluster=CLUSTER_ID \
    --project=PROJECT_ID
  • INSTANCE_ID: The ID of the instance.
  • REGION_ID: The region where the instance is placed.
  • CLUSTER_ID: The ID of the cluster where the instance is placed.
  • PROJECT_ID: The ID of the project where the cluster is placed.