Courseiva
PCDEChapter 10 of 18Objective 3.1

High Availability and Disaster Recovery for Cloud Databases

Without understanding high availability and disaster recovery, you could build a database that works perfectly now but loses all customer data if a single server fails or a datacentre catches fire. That would mean lost orders, angry users, and possibly a company going out of business. This chapter explains how to design databases that survive failures and disasters, which is a core skill tested on the Google Professional Cloud Database Engineer exam.

12 min read
Intermediate
Updated Jul 23, 2026
Editorial oversight: Johnson Ajibi· Security Systems Architect · MSc IT Security · IEEE Senior Member

A simple way to picture High Availability and Disaster Recovery for Cloud Databases

The 5-Minute-Only Café Backup Plan Analogy

A small café makes 200 coffees a day. The owner has one espresso machine. If it breaks, the café closes. That is zero high availability. The owner buys a second, identical espresso machine. If the first breaks, a staff member flicks a switch, and the second machine starts making coffee. The café stays open. That is high availability (HA): having a spare ready to take over instantly so customers see no interruption.

But what if the entire café building burns down? The second machine burns too. That is a disaster, not a simple failure. For disaster recovery (DR), the owner keeps a third espresso machine in a storage unit 50 kilometres away. If the café is destroyed, the owner drives to the storage unit, retrieves the machine, and sets up a temporary stall. It takes six hours. Customers wait, but the business survives. In cloud databases, HA is the spare machine in the same room. DR is the backup machine in a different city. The café owner also writes down the recipe for every drink on a waterproof card stored with the machine 50km away. That card is a database backup. The 50km distance is the geographic region separation. A cloud engineer designs both the spare machine (HA) and the remote machine (DR) so a fire — or a server failure — never destroys the business forever.

How It Actually Works

High availability (HA) and disaster recovery (DR) are two strategies to keep your database working when things go wrong, but they solve different problems. HA is about surviving small, local failures quickly. DR is about surviving big, catastrophic failures that destroy an entire location.

Let us start with high availability. The goal of HA is to minimise downtime — the time your database is unavailable. Downtime is measured in nines. Three nines means 99.9% uptime, which allows about 8.7 hours of downtime per year. Five nines means 99.999% uptime, which allows only about 5.26 minutes of downtime per year. To achieve HA, you need redundancy: multiple copies of the same data running on different servers.

In Google Cloud SQL, HA is built using a primary instance and a standby instance. The primary instance handles all your database reads and writes. The standby instance sits idle in a different zone within the same region. A zone is one datacentre. A region is a geographic area with multiple zones, like us-central1. When the primary fails — for example, its server crashes — Google Cloud automatically switches traffic to the standby. This process is called a failover. The standby becomes the new primary immediately. You do not need to change your application code because the connection string (the address your app uses to talk to the database) stays the same. The small gap during failover is usually under 60 seconds.

Cloud Spanner, Google’s globally distributed database, gives HA by design. It automatically replicates your data across multiple zones within a region, or even across regions. If one zone fails, Spanner uses a consensus protocol called Paxos to choose a new leader replica. Your application keeps working with no downtime. You do not need to configure a separate standby because Spanner manages its own redundancy.

Now for disaster recovery. DR handles events that take out an entire region, such as a major earthquake, a power grid failure, or a software bug that corrupts data across all zones in a region. DR requires you to have a copy of your data in a different region. In Cloud SQL, you set up a cross-region replica. This replica asynchronously receives changes from the primary. That means there is a small delay — usually a few seconds — between a write on the primary and that write appearing on the replica. This delay is called replication lag. If a disaster happens, you can promote the replica to become a new primary. You will lose any data that had not yet been replicated (the lagged data). This data loss is measured by the recovery point objective (RPO). You also have a target for how long it takes to get the new database running: the recovery time objective (RTO). For example, you might set an RPO of 15 minutes (you accept losing up to 15 minutes of recent data) and an RTO of 2 hours (you want the database back within 2 hours).

Cloud Spanner handles DR differently. You can configure a multi-region configuration, such as nam3 which uses regions in North America. Spanner automatically keeps your data consistent across all regions. If one region fails, Spanner continues serving from the other regions. There is no failover time and no data loss because the data is synchronously replicated — every write is written to multiple regions before the database confirms success. Synchronous replication means zero lag, but it adds latency because your application must wait for the write to reach the distant region.

Other services also have HA and DR options. Bigtable, Google’s NoSQL database, offers replication within a single cluster (for HA) and across clusters (for DR). Firestore uses multi-region replication automatically. Memorystore, Google’s managed Redis, provides a standard tier (single server) and a high-availability tier (with a replica).

In summary, HA keeps your database running through local failures with fast failover. DR keeps your business alive through region-wide disasters by maintaining separate copies in another location. A complete database design uses both, because HA alone cannot survive a regional disaster, and DR alone cannot give you instant failover for a simple server crash.

This diagram shows the difference between Cloud SQL HA (standby in another zone) and DR (cross-region replica), alongside Cloud Spanner's multi-region automatic failover approach.

Walk-Through

1

Assess the Recovery Objectives

Determine your RPO and RTO. For example, the business may decide it can lose 5 minutes of data (RPO = 5 minutes) and needs the database back within 1 hour (RTO = 1 hour). These values drive every decision about whether to use HA, DR, or both, and which services to choose.

2

Enable High Availability on the Primary Instance

For Cloud SQL, edit the instance and select High Availability. This creates a standby instance in a different zone within the same region. The standby does not accept traffic until failover. This step protects against a single zone failure and meets RTO targets under 60 seconds.

3

Create a Cross-Region Replica for Disaster Recovery

In Cloud SQL, create a read replica in a different region. This replica asynchronously replicates data from the primary. Monitor replication lag to ensure it stays within your RPO. If a region-wide disaster occurs, you can promote this replica to a new primary instance.

4

Document and Practise the Disaster Recovery Runbook

Write down every command and step needed to promote the cross-region replica, update DNS, and verify data integrity. Test this procedure regularly in a non-production environment. Each practise reveals issues like DNS caching delays or missing permissions, allowing you to refine the runbook before a real disaster.

5

Monitor Health and Replication Lag

Set up Cloud Monitoring alerts for the primary instance’s health and for replication lag on the cross-region replica. For example, an alert triggers if lag exceeds 30 seconds. This proactive monitoring lets you detect problems early and decide if a manual failover is needed before a true disaster occurs.

What This Looks Like on the Job

You work as a junior database engineer at a retail company called ShopNow. ShopNow runs an e-commerce website that processes 10,000 orders per hour. The database is a Cloud SQL PostgreSQL instance. Your manager tells you that last month, a single zone in us-central1 lost power for 45 minutes. ShopNow was down for the whole 45 minutes because it had only a single database instance. The company lost USD$600,000 in sales. Now you have been asked to design a high availability and disaster recovery solution.

You start by enabling HA on the existing Cloud SQL instance. In the Google Cloud Console, you edit the instance and choose High Availability. Cloud SQL automatically creates a standby instance in a different zone within us-central1. The failover happens in under 60 seconds. Now if one zone fails, the website keeps running. But you know this does not protect against a disaster that affects the entire us-central1 region, such as a widespread tornado.

For disaster recovery, you create a cross-region replica in us-west2. The replica asynchronously replicates data from the primary. You test the replication lag and find it is typically 3-5 seconds. You decide on an RPO of 5 seconds — you accept losing no more than 5 seconds of orders if a disaster happens. You set an RTO of 1 hour: you want the new database running within 60 minutes. You document a disaster recovery runbook that includes these steps:

Identify that a disaster has occurred using Cloud Monitoring alerts. Alerts fire when the primary instance becomes unreachable across multiple regions.

Promote the cross-region replica in us-west2 to become a standalone primary instance. Use the gcloud command 'gcloud sql instances promote-replica'.

Update the application’s connection string to point to the new primary’s IP address. You use a DNS CNAME record so you only need to change one DNS entry.

Verify that the website is serving orders from the new database. Check that all tables are present and recent data is available.

Monitor replication lag on any remaining replicas and decide if you need to create a new cross-region replica from the promoted primary for future protection.

You also practise this failover quarterly. In a test, you force a simulated disaster by deleting the primary instance's data. Your team promotes the replica. The first time, it takes 2 hours because the DNS cache had not been cleared. You update the runbook to flush DNS first. The second drill completes in 45 minutes. Your manager approves your design.

For Cloud Spanner, you would take a different approach. If ShopNow used Spanner, you would configure a multi-region instance. You would select the nam3 configuration, which includes us-central1, us-east1, and us-west1. Spanner automatically routes reads to the nearest region and handles regional failures without downtime. You do not need a separate HA standby because Spanner has built-in redundancy. You still practise disaster scenarios: you simulate a region outage by blocking network traffic from one region using VPC firewall rules, then verify that the application continues to serve from the other regions without any manual action.

How PCDE Actually Tests This

The Google PCDE exam tests your understanding of high availability and disaster recovery for Cloud SQL, Cloud Spanner, and other managed database services. You will see scenario-based multiple-choice questions that ask you to choose the best configuration for a given requirement. The exam does not ask you to remember specific gcloud commands in detail, but you must understand the concepts and the differences between services.

Key exam topics for this objective:

The difference between zonal failover (HA) and regional disaster recovery (DR). The exam will present a scenario like 'an application needs to survive a single zone failure with less than 1 minute of downtime'. The correct answer is to enable HA on Cloud SQL, which creates a standby in another zone.

Recovery point objective (RPO) and recovery time objective (RTO). You must be able to match these values to the correct service. For example, if the requirement is RPO of 0 (no data loss), Cloud SQL cross-region replication is not sufficient because it is asynchronous. The correct answer may be Cloud Spanner with multi-region configuration, which uses synchronous replication and achieves zero data loss.

The trade-offs between synchronous and asynchronous replication. Synchronous replication (Spanner multi-region) gives zero RPO but higher write latency. Asynchronous replication (Cloud SQL cross-region replica) gives lower latency but some data loss risk.

The components of Cloud SQL HA: primary instance, standby instance, and the failover process. The standby must be in a different zone but in the same region. The failover is automatic and typically completes within 60 seconds.

The difference between a read replica and a disaster recovery replica. A read replica can handle read-only traffic and can be promoted in a disaster. A DR replica specifically refers to a cross-region replica used for disaster recovery.

For Cloud Spanner: multi-region configurations, the Paxos consensus protocol, and automatic failover. The exam loves to test that Spanner does not require manual failover steps like Cloud SQL does.

For other services like Bigtable and Firestore: knowing whether they have built-in HA or require manual configuration. Firestore has multi-region replication enabled by default. Bigtable requires cluster replication.

Traps the exam sets:

They give an RTO of 5 minutes and an RPO of 1 hour. Many test-takers instinctively choose the fastest option, but you must consider that a very low RTO may require a more expensive synchronous solution. The cheapest option that still meets both RTO and RPO is correct.

They present a scenario where the database is used for analytics and can tolerate several hours of downtime. The incorrect answer uses a high-availability configuration that is expensive and unnecessary. The correct answer is a simple scheduled backup with a longer RTO.

They describe a disaster that affects two zones in the same region. Test-takers might choose a cross-region replica, but a zonal HA standby in a third zone might be sufficient and cheaper. You must read the question carefully: are they saying 'all zones in the region' or 'two zones out of three'?

They ask about Cloud SQL and include 'multi-region' in an answer. Cloud SQL supports cross-region replicas but does not have true multi-region synchronous replication like Spanner. If you see 'multi-region' for Cloud SQL, it is usually a trap. The correct term is 'cross-region replica'.

Definitions to memorise:

RPO: the maximum acceptable amount of data loss measured in time.

RTO: the maximum acceptable time to restore service after a disaster.

Failover: the process of switching to a standby system.

Replication lag: the delay between writing data on the primary and it appearing on a replica.

Zone: a single datacentre within a region.

Region: a geographic area containing multiple zones.

Key Takeaways

High availability protects against zone failures within a single region, while disaster recovery protects against region-wide failures.

Cloud SQL HA uses a standby instance in a different zone and provides automatic failover in under 60 seconds.

Cloud SQL cross-region replicas use asynchronous replication, meaning there is always a small window of potential data loss (measured by RPO).

Cloud Spanner multi-region configurations use synchronous replication and provide zero data loss with automatic failover across regions.

The recovery point objective (RPO) defines how much data you are willing to lose, measured in time; the recovery time objective (RTO) defines how quickly you must restore the database.

For Cloud SQL, you must manually promote a cross-region replica to a primary instance during a disaster; this promotion is not automatic.

Cloud Spanner does not require manual failover steps; it handles regional failures transparently using the Paxos consensus protocol.

When designing HA and DR, always balance cost against the required RPO and RTO; a solution that meets both at the lowest cost is typically the correct exam answer.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

Cloud SQL HA (Zonal Failover)

Automatic failover in under 60 seconds

Standby is in a different zone but same region

No data loss during failover (RPO = 0 for the local failure)

Cloud SQL Cross-Region Replica (DR)

Manual promotion required during disaster

Replica is in a different region

Potential data loss equal to replication lag (RPO > 0)

Cloud SQL HA with Cross-Region Replica

HA failover is automatic; DR promotion is manual

RPO is non-zero for DR (asynchronous replication)

Lower cost for moderate RPO/RTO requirements

Cloud Spanner Multi-Region

Both HA and DR are automatic and transparent

RPO is zero (synchronous replication across regions)

Higher cost due to synchronous replication across multiple regions

Asynchronous Replication

Primary does not wait for replica to confirm writes

Lower write latency

Risk of data loss if primary fails before replication completes

Synchronous Replication

Primary waits for all replicas to confirm writes

Higher write latency (especially across long distances)

Zero data loss after a failure

Recovery Point Objective (RPO)

Measures acceptable data loss in time

Example: RPO of 5 minutes means losing 5 minutes of recent data is acceptable

Drives the choice of replication method (async vs sync)

Recovery Time Objective (RTO)

Measures acceptable downtime after a failure

Example: RTO of 2 hours means the database must be running again within 2 hours

Drives the choice of failover method (manual vs automatic)

Watch Out for These

Mistake

High availability and disaster recovery are the same thing, just named differently.

Correct

HA focuses on surviving single-component failures with fast failover (seconds to minutes), while DR focuses on surviving full-region failures with longer recovery times (minutes to hours). They solve different problems and require different configurations.

Both terms involve keeping the database running, and many beginners use them interchangeably. Marketing materials often blur the lines, but the exam tests the distinction.

Mistake

If I enable HA on Cloud SQL, it automatically protects my data from a region-wide disaster.

Correct

Cloud SQL HA only protects against a zone failure within the same region. If the entire region goes down, the standby in a different zone also fails. You need a cross-region replica for DR.

The word 'high availability' sounds comprehensive, so beginners assume it covers everything. They do not realise that HA is limited to a single region.

Mistake

I need to manually trigger a failover for Cloud SQL HA when the primary fails.

Correct

Cloud SQL HA failover is automatic. When the primary becomes unhealthy, Google Cloud detects it and promotes the standby without manual intervention. You do not need to run any commands.

Many beginners come from an on-premises background where they had to manually fail over databases. The fully managed nature of Cloud SQL is a key selling point that is easy to overlook.

Mistake

Cross-region replicas in Cloud SQL use synchronous replication, so there is zero data loss during a disaster.

Correct

Cross-region replicas use asynchronous replication. There is always a small delay, so some data may be lost if the primary fails before the replica catches up. Only Cloud Spanner multi-region configurations provide synchronous replication with zero data loss.

The term 'replica' suggests an exact copy, so beginners assume it is always up-to-date. They do not understand that the distance between regions introduces latency that makes synchronous replication impractical for Cloud SQL.

Mistake

Cloud Spanner requires me to configure a separate standby instance for high availability, just like Cloud SQL.

Correct

Cloud Spanner has built-in high availability. It automatically replicates data across multiple machines and zones. You do not need to configure a standby. The multi-region configuration is for DR, not for basic HA.

People learn the Cloud SQL model first (primary + standby) and then incorrectly apply that same pattern to every other database service. Spanner’s architecture is fundamentally different.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

What is the difference between a read replica and a disaster recovery replica in Cloud SQL?

A read replica is used to offload read-only queries and can be in the same region or a different region. A disaster recovery replica is specifically a cross-region replica that you promote to a primary during a disaster. In practice, a cross-region read replica can serve both purposes, but a DR replica is defined by its role in a recovery plan.

Does enabling HA on Cloud SQL double my costs?

Yes, you pay for both the primary and the standby instance. The standby charges the same compute and storage costs as the primary. However, you do not pay for data transfer between zones in the same region.

Can I use Cloud SQL cross-region replication for zero data loss?

No. Cross-region replication in Cloud SQL is asynchronous, meaning there is always a delay. If a disaster happens during that delay, you lose the most recent writes. For zero data loss, you need a database that supports synchronous replication across regions, such as Cloud Spanner.

How long does a Cloud SQL HA failover actually take?

Google states that the failover is typically completed within 60 seconds. The actual time depends on the database workload and the reason for the failure. In practice, most failovers complete in 30-40 seconds.

What happens to my existing connections when a Cloud SQL failover occurs?

All existing connections to the primary are dropped. Your application must be able to re-establish connections. Google recommends using connection pooling and retry logic in your application code so that it automatically reconnects to the standby without errors.

Does Cloud Spanner cost more than Cloud SQL for HA and DR?

Generally, yes. Cloud Spanner multi-region instances are more expensive than a Cloud SQL instance with a cross-region replica. The cost difference is justified if you require zero downtime, zero data loss, and global scalability. For applications that can tolerate some downtime and data loss, Cloud SQL with HA and a cross-region replica is more cost-effective.

Terms Worth Knowing

Keep going

You've finished High Availability and Disaster Recovery for Cloud Databases. Continue through the PCDE study guide to build a complete picture of the exam.

Done with this chapter?