RDS vs. Cloud SQL PostgreSQL: What Happens When a Zone Fails?
A database failover can succeed while the application remains unavailable: existing sessions are gone, clients may hold stale addresses, and an interrupted transaction can leave its outcome uncertain.
TL;DR
- Problem: “Multi-zone” hides incompatible replication paths—storage-level sync versus engine-level semisync—and client pools can turn a 35–120 second provider failover into a multi-minute outage.
- Answer: Match the topology to your read-scaling and failover-speed requirements, then bound client recovery with short DNS TTLs (5 seconds or less on RDS), pool pre-ping validation, and idempotent write reconciliation.
- Watch out: Neither RDS Multi-AZ standby nor Cloud SQL Regional HA standby serves read traffic, and Cloud SQL handles memory or disk exhaustion with an in-place restart rather than a zone failover.
Situation
An enterprise running PostgreSQL on Amazon RDS often starts with a Multi-AZ DB instance: one writer, one synchronous standby in a second Availability Zone, and an application connecting through a single RDS endpoint. A move to Google Cloud—or a multi-cloud architecture standard—raises a deceptively simple question: is Cloud SQL Regional HA the same architecture under another name?
Both configurations protect against a primary compute failure or an Availability Zone outage, and both carry a 99.95% monthly uptime SLA on their standard tiers (rising to 99.99% on Cloud SQL Enterprise Plus). Yet their underlying replication boundaries, readable-standby behavior, DNS versus IP cutover mechanics, and maintenance interactions differ. Those differences matter the moment a design includes read scaling, strict recovery time objectives (RTO), or automated application retry logic.
This comparison covers Amazon RDS for PostgreSQL (Multi-AZ DB instance and Multi-AZ DB cluster) and Google Cloud SQL for PostgreSQL (Enterprise and Enterprise Plus with Regional HA). Amazon Aurora and Google AlloyDB use distributed storage architectures and are outside the scope of this series.
The Problem
The phrase “multi-zone database” conceals four independent operational questions. First, is the standby a running, readable PostgreSQL instance or a passive failover target? Second, does a transaction commit wait for another database engine or for a replicated block-storage volume? Third, how do clients discover the new writer after promotion? Fourth, does a separate read replica participate in automatic primary failover?
Four concrete constraints govern whether a failover meets its availability target:
- Monthly downtime budget: A 99.95% monthly uptime SLA permits at most
0.0005 × 43,200 = 21.6minutes of total unavailability in a 30-day month. A 99.99% SLA (Cloud SQL Enterprise Plus) narrows that budget to4.32minutes per month. - Provider failover interval: AWS documents typical failover times of 60–120 seconds for an RDS Multi-AZ DB instance and under 35 seconds for an RDS Multi-AZ DB cluster. Google Cloud documents roughly 60 seconds of unavailability as an expectation for Cloud SQL Enterprise Regional HA, with Enterprise Plus targeting faster recovery and under 1 second of connectivity interruption for eligible planned maintenance.
- DNS caching and socket timeouts: AWS updates the RDS endpoint CNAME record with a 5-second DNS TTL, yet a default Java Virtual Machine (JVM) without explicit security overrides caches DNS lookups indefinitely until restart. Meanwhile, half-open TCP sockets in a connection pool wait for OS or driver read timeouts (often 30–60 seconds) unless evicted by health checks.
- Total outage math: Even if an RDS Multi-AZ DB instance fails over in 90 seconds, a 45-second socket read timeout plus a misconfigured 300-second DNS cache pushes application recovery to
90 + 45 + 300 = 435seconds (7.25minutes)—consuming one-third of a 99.95% monthly budget in a single event.
A team that assumes every secondary is both readable and eligible for automatic promotion can under-provision its readers or write a recovery plan that never executes. A team that assumes the database endpoint preserves existing connections will discover its connection pool keeps issuing requests to dead sockets.
What exactly is protected, and what must the application do, when a zone fails?
Options Considered
Selecting a PostgreSQL HA topology requires balancing failover speed, read-scaling coupling, and monthly SLA targets. Single-AZ deployments are rejected for production writers because they provide no automatic zone failover and carry no multi-zone SLA.
| Option | Replication Path | Typical Failover | Monthly SLA | Readable Standby | Why Chosen or Rejected |
|---|---|---|---|---|---|
| Single-AZ Instance | None (local zone only) | Manual restore | Lower tier | No | Rejected for production; single zone failure causes extended outage |
| RDS Multi-AZ DB Instance | Sync block/instance to 1 standby | 60–120 seconds | 99.95% | No | Chosen for simple 2-AZ HA when read offload is separate or unneeded |
| RDS Multi-AZ DB Cluster | Semisync engine WAL to 2 readers | Under 35 seconds | 99.95% | Yes (2 readers) | Chosen when sub-minute failover and built-in read scaling justify 3-AZ cost |
| Cloud SQL Enterprise HA | Sync Regional Persistent Disk | ~60 seconds | 99.95% | No | Chosen for standard GCP zonal HA with preserved endpoint IP |
| Cloud SQL Enterprise Plus HA | Sync Regional Persistent Disk | Faster than Enterprise | 99.99% | No (use read pools) | Chosen when 99.99% SLA and <1s planned maintenance justify tier cost |
Choosing between RDS Multi-AZ DB instance and Multi-AZ DB cluster comes down to whether you want read scaling coupled to your HA quorum. A Multi-AZ DB cluster runs three full compute instances across three AZs and requires at least one reader to acknowledge WAL before commit. If your workload does not need two readable standbys, paying for three compute nodes adds cost without benefit. Conversely, on Google Cloud, Cloud SQL Enterprise Plus separates HA from read scaling: you pay for Regional HA to protect the writer and optionally add read-pool nodes when read concurrency demands it.
Three HA Architectures, Three Different Paths
The three multi-zone topologies protect against zone loss through distinct control-plane and storage mechanisms. The schematic below compares their logical protection paths; it does not imply identical commit protocols.
flowchart TD
subgraph A[Amazon RDS — Multi-AZ DB instance]
A1[Zone A — writer] -->|synchronous standby| A2[Zone B — non-readable standby]
end
subgraph B[Amazon RDS — Multi-AZ DB cluster]
B1[Zone A — writer] -->|semisynchronous| B2[Zone B — readable standby]
B1 -->|semisynchronous| B3[Zone C — readable standby]
end
subgraph C[Cloud SQL — Regional HA]
C1[Zone A — primary compute] --> C2[Regional storage — synchronous copies across zones]
C2 --> C3[Zone B — standby compute]
end
RDS Multi-AZ DB instance
In an RDS Multi-AZ DB instance deployment, AWS provisions a primary instance in one Availability Zone and a synchronous standby in a second AZ. The standby exists strictly for availability; it does not accept client connections or serve read queries. When a qualifying outage occurs—such as primary host failure, AZ loss, or storage failure—RDS promotes the standby and updates the database endpoint’s DNS CNAME record to point to the standby’s IP address.
AWS documents failover times of 60–120 seconds for Multi-AZ DB instances, though large uncommitted transactions or crash recovery can extend that window. Because clients resolve a DNS CNAME, DNS TTL handling and connection-pool eviction directly determine when application traffic resumes. A separate RDS read replica can offload reads, but it uses asynchronous replication and is not an automatic HA failover target.
RDS Multi-AZ DB cluster
An RDS Multi-AZ DB cluster deploys one writer DB instance and two readable standby DB instances across three Availability Zones. Unlike a traditional Multi-AZ instance, the cluster uses engine-native semisynchronous replication: a write transaction commits once at least one of the two reader instances acknowledges receipt of the WAL record. Because only one reader must acknowledge before commit, the second reader may trail slightly behind.
During failover, RDS selects the reader with the lowest replica lag, finishes applying any queued transactions, and promotes it to writer—typically completing in under 35 seconds. The cluster exposes both a writer endpoint and a reader endpoint. However, because a reader can serve state behind the writer even while participating in HA, applications must not infer read-your-writes consistency from the reader endpoint.
Cloud SQL Regional HA
Cloud SQL Regional HA deploys a primary VM in one zone and a standby VM in a secondary zone backed by Regional Persistent Disk, which replicates block writes synchronously across both zones before acknowledging a commit. The standby VM remains idle until failover and cannot serve read traffic. When the primary becomes unresponsive, Cloud SQL activates the standby VM against the shared regional disk and rebinds the instance’s primary IP address—typically causing about 60 seconds of unavailability on Enterprise Edition, with faster recovery on Enterprise Plus.
A separate Cloud SQL read replica—even one placed in a third zone—uses asynchronous replication and does not become an automatic HA failover target for the primary. You can enable HA on a read replica to protect the replica’s own uptime, but that does not alter the primary’s promotion path.
To enforce clean client recovery and secure transport on RDS, configure JVM DNS caching to match AWS’s 5-second TTL and require TLS on cluster parameter groups, while enabling Regional HA explicitly on Cloud SQL:
// Set before initializing connection pools in Java services targeting RDS
java.security.Security.setProperty("networkaddress.cache.ttl", "5");
java.security.Security.setProperty("networkaddress.cache.negative.ttl", "10");
# Enable Regional HA on an existing Cloud SQL for PostgreSQL instance
gcloud sql instances patch my-pg-instance \
--availability-type=REGIONAL
How It Rolls Out
A database failover has four sequential stages, and the provider only controls the first two. Treating provider promotion as the finish line leaves applications vulnerable to hung threads and duplicate writes.
- Detect and promote (Provider control plane): Health checks detect primary unavailability. On RDS Multi-AZ DB instance, the standby mounts storage and runs PostgreSQL crash recovery. On RDS Multi-AZ DB cluster, the lowest-lag reader applies remaining WAL and promotes. On Cloud SQL Regional HA, the standby compute instance attaches to the synchronized Regional Persistent Disk and starts PostgreSQL.
- Rebind endpoint (Provider network): RDS updates the CNAME record for the writer endpoint with a 5-second TTL. Cloud SQL reattaches the instance’s static IP address or Cloud SQL Auth Proxy identity to the newly active standby zone and terminates all prior TCP sessions.
- Reconnect pool (Application runtime): Application connection pools detect broken sockets via pre-ping validation queries (such as
SELECT 1) or short socket read timeouts, evict dead connections, re-resolve DNS if on RDS, and establish fresh TLS sessions. Placing Amazon RDS Proxy or PgBouncer in front of the database can absorb connection storms during this step, though proxy-side health checks still add a brief transition window. - Reconcile writes (Application logic): Any transaction that was in flight when the primary died returns a connection reset or timeout to the caller. Because the commit may have succeeded on the old primary just before the socket broke, the application must query an idempotency record or durable operation log before retrying state-changing writes.
To validate this sequence before production cutover, roll out HA testing in three gated stages: first, trigger a manual failover in staging and verify that DNS TTL and pool pre-ping evict dead sockets within 15 seconds of provider promotion; second, inject an in-flight write during failover to confirm idempotency reconciliation prevents duplicate records; third, run a controlled failover during a low-traffic production window and record the exact timestamp of the last good write, first error, endpoint switch, and first successful business transaction. If client recovery exceeds your RTO budget at any gate, tighten pool timeouts or introduce a connection proxy before proceeding.
In Practice
The documented Cloud SQL failover sequence illustrates why monitoring must distinguish infrastructure failovers from engine restarts. When a Cloud SQL Regional HA primary becomes unresponsive due to a host or zone failure, health checks trigger failover and the standby begins serving from the secondary zone. Once the original zone recovers, the former primary is recreated as the new standby; returning the primary role to the original zone requires an explicit failback operation. However, Google documents that resource exhaustion events—such as out-of-memory (OOM) crashes from unbounded work_mem or runaway connection counts—can trigger an in-place instance restart rather than a zone failover. Alerts that assume every outage produces a zone-change event will misclassify OOM restarts.
On Amazon RDS, documented DNS behavior dictates how runtime validation must be designed. Because AWS updates a CNAME record with a 5-second TTL, testing failover only from a psql CLI session misses runtime-specific DNS caches in Java, Node.js, or sidecar proxies. Testing must occur from the actual application container and runtime, recording five timestamps: last successful write, first client error, DNS resolution change, first successful reconnect, and first completed business transaction. The gap between provider recovery and application recovery is almost always where unconfigured caches or pool timeouts surface.
Finally, PostgreSQL transaction semantics create a hard boundary during any abrupt failover: if a client issues COMMIT and loses the TCP connection before receiving the CommandComplete response, the client cannot know whether the server committed the transaction to WAL (and replicated it to the standby) before dying. Reconnection alone never resolves this ambiguity; durable idempotency keys are mandatory for payments, ledger entries, and order creation.
Where It Breaks
Even well-architected HA deployments fail when client behavior, engine resource limits, or regional boundaries are misunderstood.
| Condition | Breaks How | Detect | Mitigate |
|---|---|---|---|
| Stale DNS cache on RDS | Runtime continues dialing retired primary IP after CNAME flip | Connection timeouts persist >120s after RDS failover event | Set JVM networkaddress.cache.ttl=5 or route via RDS Proxy |
| Dead sockets in pool | Pool hands half-open TCP connections to callers until OS timeout | Spike in read-timeout errors across multiple app pods | Enable pool_pre_ping / validation queries and bound socket timeouts |
| Unknown commit outcome | Blind retry of timed-out COMMIT duplicates business action | Duplicate rows or payment charges following failover | Require idempotency keys and reconcile before retrying writes |
| Stale reads on RDS Cluster | Reader endpoint serves lagging standby state after write | Read-after-write anomalies in user workflows | Route strict freshness reads to the writer endpoint |
| OOM or disk exhaustion | Cloud SQL restarts in place rather than failing over to standby | Instance restart logs without zone-change event | Cap max_connections, bound work_mem, alert at 85% memory |
| Standby or secondary unhealthy | Secondary zone degradation blocks automatic promotion | Provider HA health status degrades to non-redundant | Monitor HA replication health alerts and repair promptly |
| Read replica mistaken for HA | Team expects async read replica to auto-promote on primary loss | Runbook stalls waiting for replica promotion that never fires | Document exact HA failover path separately from read replicas |
| Entire region unavailable | Both primary and standby zones fail together | Regional control-plane and multi-zone connectivity loss | Implement cross-region disaster recovery (covered in Part 2) |
Key Takeaways
- HA topology and read scaling are separate decisions: RDS Multi-AZ DB instances and Cloud SQL Regional HA use non-readable standbys; only RDS Multi-AZ DB clusters couple HA with two readable standbys across three AZs.
- Client recovery dominates total outage time: Provider failover takes 35–120 seconds, but unconfigured DNS caches and unvalidated connection pools can stretch application downtime well past your 99.95% monthly budget.
- Cloud SQL OOM events restart in place: Exhausting memory or local resources triggers a local restart rather than a standby failover; bound PostgreSQL memory parameters and monitor utilization before it hits 90%.
- Semisynchronous clusters can serve stale reads: An RDS Multi-AZ DB cluster commits after one reader acknowledges WAL, meaning the second reader can lag behind recent writes.
- Reconnection does not resolve in-flight commits: Any
COMMITinterrupted by a socket drop has an unknown outcome and requires application-level idempotency keys before retry.
What to Do Next
- Problem: Identify every application workflow that cannot tolerate duplicate writes or 60–120 seconds of write unavailability during a zone failure.
- Solution: Select the HA topology that matches your SLA and read-scaling needs, then configure DNS TTLs (<=5 seconds on RDS), pool pre-ping validation, and idempotency keys.
- Proof: Trigger a controlled failover in staging from the actual application runtime and measure the interval from the last successful write to the first successful business transaction.
- Action: Document the exact endpoint behavior, DNS/pool settings, OOM restart distinction, and write reconciliation steps in your service runbook this week.