Cloud and Managed Database Services Questions
Running databases as managed cloud services rather than self-hosting them: choosing and provisioning managed relational and NoSQL offerings (for example Amazon RDS/Aurora/DynamoDB, Azure SQL Database/Cosmos DB, Google Cloud SQL/Spanner), sizing instances and storage, and designing an architecture (read replicas, connection proxies and pooling for managed or serverless compute) to meet a latency or availability target. It covers comparing provisioned versus serverless/autoscaling pricing and operational models, forecasting capacity and cost, and migrating a database onto or between managed deployments: moving a self-hosted database to a managed service, switching a workload from provisioned to serverless (or back), changing a single-AZ deployment to multi-AZ, and the questions to ask before adopting a new managed vendor. The core question is the split of responsibility and cost between the cloud provider and the engineering team: what the provider takes on (patching, infrastructure-level HA, automated backups) versus what remains the team's job (configuration, capacity and cost tuning, security posture like encryption and key rotation). It does not cover backup and restore mechanics, RPO/RTO planning, replication or sharding internals, or SQL-level query diagnostics.
Describe how you would deploy a managed relational database for a production web application. Cover service selection (RDS/Aurora/Cloud SQL/Managed MySQL), sizing (instance class, storage type), read scaling, encryption, maintenance windows, and routine maintenance practices.
Sample Answer
Deploying a managed relational database for production is five deliberate decisions, not one "create instance" click: which service, what size, whether you need read scaling yet, encryption configured before first write, and a maintenance window you chose rather than accepted by default.
Service selection
- Amazon RDS: the broadest engine choice (MySQL, PostgreSQL, MariaDB, SQL Server, Oracle, Db2), engine-native replication, and the most flexible instance sizing including small burstable classes. The default choice for most web applications unless you have a specific reason to want more.
- Amazon Aurora: MySQL- and PostgreSQL-compatible, with storage-layer replication instead of engine-level replication, which gives materially faster failover (automatically switching to a healthy standby when the primary fails) and a higher write-throughput (the volume of write operations the database can sustain per second) ceiling on the largest instance classes. Worth the higher baseline cost when you expect to outgrow a single well-tuned RDS instance, or when failover speed matters more than for a typical web app.
- Cloud SQL: Google Cloud's equivalent to RDS for MySQL, PostgreSQL, and SQL Server, same category of decision as RDS on AWS.
For a typical production web application starting out, RDS or Cloud SQL on the engine your team already knows is the right default; reach for Aurora specifically when you can point to a concrete scaling reason, not by default.
Sizing: instance class and storage type
Pick the instance class from measured or realistically estimated CPU and memory need with headroom, not a round number picked for comfort. Storage type matters as much as instance class:
- gp3 (general purpose SSD): the right default for most online transaction processing (OLTP) workloads. It decouples provisioned IOPS (input/output operations per second: the count of individual read or write operations the volume can handle each second, distinct from throughput's raw bytes-per-second measure) and throughput from allocated storage size, so you are not forced to over-allocate storage just to get more IOPS.
- io2 / io2 Block Express: for latency-sensitive, very high-IOPS workloads where gp3's ceiling is not enough; costs more per provisioned IOPS.
- Enable storage autoscaling so unplanned data growth raises allocated storage automatically instead of the instance running out of space and rejecting writes.
Read scaling
Add a read replica only when there is a specific, measured reason: reporting or analytics queries competing with transactional traffic for CPU and I/O, or read throughput that a single writer genuinely cannot serve even with caching in front of it. A read replica is a full additional instance (real cost, real operational surface via replication lag, the delay before a write on the primary becomes visible on the replica), not a free performance knob, so route only the traffic that needs it, typically through RDS Proxy or explicit read/write splitting in the application, rather than defaulting every read query to a replica.
Encryption
Enable storage encryption at creation time: RDS cannot add encryption to an existing unencrypted instance in place, only by snapshotting it, copying the snapshot with encryption enabled, and restoring from that copy, so getting this right on day one avoids a disruptive migration later. The AWS-managed key (which AWS automatically rotates every year) is sufficient for most applications; use a customer-managed KMS (Key Management Service) key only when you need explicit control over key policy or rotation cadence, for example a compliance requirement to control who can disable access to the key. Separately, enforce TLS (transport layer security) on connections at the engine level, rds.force_ssl for PostgreSQL or require_secure_transport for MySQL, since encryption at rest alone does not protect credentials and query data in flight between the application and the database.
Maintenance windows and routine maintenance
If you do not set a maintenance window explicitly, RDS assigns a random 30-minute window in your region, which may land during business hours. Choose one deliberately, during genuinely low-traffic hours for your actual user base, and prefer applying non-urgent changes during that window rather than immediately, so patches land predictably instead of mid-peak-traffic. Keep automatic minor-version upgrades on for security patches, but review major version upgrades manually since those can carry breaking changes to the engine's behavior. As routine practice: review the instance's "pending maintenance actions" on a regular cadence rather than being surprised by them, audit the parameter group for drift from intended settings after any manual tuning, and revisit instance rightsizing on a schedule (for example quarterly) instead of only reacting once performance has already degraded.
Worked example: a concrete creation command
aws rds create-db-instance \
--db-instance-identifier prod-webapp-db \
--engine postgres --engine-version 16.4 \
--db-instance-class db.r6g.xlarge \
--allocated-storage 200 --storage-type gp3 --iops 6000 --storage-throughput 250 \
--max-allocated-storage 500 \
--storage-encrypted --kms-key-id alias/prod-db-key \
--preferred-maintenance-window "sun:05:00-sun:06:00" \
--auto-minor-version-upgrade
This encodes the sizing decision (an r6g.xlarge, memory-optimized Graviton instance class, a common default for a moderate production web app), gp3 storage with explicit IOPS and throughput rather than whatever the default happens to be, storage autoscaling up to 500 GiB so growth does not hit a hard wall, encryption specified at creation with a named key, a chosen (not default) maintenance window, and automatic minor-version patching. Multi-AZ and backup retention are deliberately left off this example: they are availability and disaster-recovery decisions with their own trade-offs, not part of the base provisioning choice this question is about.
Trade-offs and pitfalls
- Defaulting to the largest instance class "to be safe" wastes money every hour it runs oversized; defaulting to the smallest "to save money" invites a production incident the first time traffic grows. Size from data, and revisit it, rather than picking once and forgetting.
- Adding a read replica before you have a measured reason adds real operational surface (monitoring replica lag, routing logic) for no benefit, and it is easy to add one reflexively because "that's what scaling a database looks like."
- Forgetting to set storage encryption before the first write is the single most expensive mistake in this list to fix later, since fixing it means a snapshot-copy-restore cycle on a live database rather than a config change.
- Accepting the default maintenance window is a common, easily avoided source of an unplanned mid-day blip; it costs nothing to set deliberately at creation time.
Your team is evaluating three ways to run the primary database for the next three years: a managed RDBMS, a self-managed cluster on VMs, and a serverless database offering. The workload has a steady 2,000 writes/sec around the clock and bursty reads that spike to 150k/sec. Compare total cost of ownership and operational burden across the three options, and say which one you would recommend and why.
Sample Answer
The recommendation is a managed RDBMS (relational database management system), specifically Aurora, running a provisioned writer for the steady write load paired with an elastic (autoscaling or Aurora Serverless v2) reader fleet for the bursty read load, for a team that does not already run a large, cross-system database operations function. That single choice beats a self-managed cluster on raw total cost of ownership (TCO) once headcount is priced in, and it beats using a fully serverless model for everything because this workload's two halves have opposite cost profiles and only one of them actually benefits from paying a serverless premium.
What TCO actually includes
Comparing these three options on infrastructure cost alone misses most of the real difference:
- Infrastructure/compute cost: the number everyone compares first, instance or ACU-hour pricing.
- Operational headcount cost: patching, backup verification, failover drills, upgrade testing, and on-call coverage. For a self-managed cluster this is a real, ongoing engineer-time cost, not a one-time setup cost, and it does not shrink because the team is small.
- Incident cost: who owns "the replication broke at 3am" and how long it takes to fix it. A managed service's automated failover and vendor support reduce, but do not eliminate, this cost; a self-managed cluster puts more of it directly and immediately on the team.
How this workload's shape drives the recommendation
The workload has two very different profiles glued together: a steady 2,000 writes/sec around the clock, and reads that burst to 150k/sec. A steady write load is exactly the case where fixed, provisioned capacity is cost-efficient, since there is no meaningful idle time to avoid paying for; metering that side per request or per capacity-unit would mean paying a serverless premium for capacity that is basically always fully used anyway, which buys no real elasticity benefit. The bursty read load is the opposite case, illustrated below. Only two numbers here come from the question itself, the 150k/sec read peak and the 2,000 writes/sec baseline; the question does not state how reads are distributed across the day, so the baseline read rate and the burst-window length are explicit, stated, illustrative assumptions (a plausible steady daytime rate and a short afternoon burst), not measured or given values, included so the calculation is checkable rather than opaque:
# Only peak_read_rps (150,000) is given by the question. The rest of the read-side inputs
# below are ILLUSTRATIVE ASSUMPTIONS, stated explicitly, standing in for "some steady baseline
# most of the day, with a short burst," since the question does not specify the daily shape.
baseline_read_rps = 20_000 # assumed illustrative baseline, NOT given by the question
peak_read_rps = 150_000 # given by the question
baseline_hours_per_day = 21 # assumed illustrative quiet-hours span
peak_hours_per_day = 3 # assumed illustrative burst-hours span
time_weighted_avg = (baseline_read_rps * baseline_hours_per_day
+ peak_read_rps * peak_hours_per_day) / 24
peak_to_avg_ratio = peak_read_rps / time_weighted_avg
UNIT_RPS = 1_000
provisioned_unit_hours_per_day = (peak_read_rps / UNIT_RPS) * 24
elastic_unit_hours_per_day = ((baseline_read_rps / UNIT_RPS) * baseline_hours_per_day
+ (peak_read_rps / UNIT_RPS) * peak_hours_per_day)
print(f"Peak-to-average read ratio: {peak_to_avg_ratio:.2f}x")
print(f"A fleet sized statically for peak buys "
f"{provisioned_unit_hours_per_day/elastic_unit_hours_per_day:.2f}x the compute-hours "
f"an elastic fleet that tracks the curve needs")
years = 3
idle_unit_hours_over_3_years = (provisioned_unit_hours_per_day - elastic_unit_hours_per_day) * 365 * years
print(f"Over {years} years, that's {idle_unit_hours_over_3_years:,.0f} unit-hours of pure idle "
f"headroom if the read fleet were statically provisioned for peak")
Peak-to-average read ratio: 4.14x
A fleet sized statically for peak buys 4.14x the compute-hours an elastic fleet that tracks the curve needs
Over 3 years, that's 2,989,350 unit-hours of pure idle headroom if the read fleet were statically provisioned for peak
This is the crux of the recommendation: under this illustrative daily shape, a read fleet statically provisioned for the 150k/sec peak sits at roughly 4x more capacity than it needs most of the day, for three years straight, while the write side has no equivalent waste to eliminate because it is already steady. Aurora lets each side use the capacity model that fits it, provisioned for the writer, elastic for the readers, under one managed database, which is why "managed RDBMS" is the recommendation among the three named options rather than a hybrid outside them.
Why not self-managed, and why not fully serverless
A self-managed cluster on VMs (virtual machines) can win on raw per-unit infrastructure cost, but that comparison only holds before counting the engineer-hours spent on 24/7 patching, backup verification, failover drills, and upgrade testing, none of which shrink for a small team the way they might be amortized across many systems for a large, dedicated database operations group. For a team without that existing capacity already in place, the "savings" tend to show up instead as slower incident response and a real chance of a costly, avoidable outage. A fully serverless offering for the whole database (for example DynamoDB on-demand, or an all-serverless relational option) is well suited to the read side's burstiness but is paying an unnecessary per-unit premium on the write side, where the load is already steady and provisioned capacity is the cheaper, equally reliable fit.
Trade-offs and pitfalls
- This recommendation is not universal, and the caveat matters as much as the pick: an organization that already runs a large, mature database operations function across many systems can genuinely find self-managed cheaper, because the headcount cost is largely sunk or shared rather than incremental to this one database. The right 3-year call depends on team size and existing operational maturity, not a single rule that applies to every org.
- Committing to a Reserved Instance or Savings Plan rate for the steady write-side capacity locks in real savings for a genuinely steady, multi-year workload, but reduces flexibility if the write pattern changes meaningfully before the commitment term ends; size that commitment against the measured baseline, not against a hopeful growth projection.
- Elastic reader capacity is only as good as its configured ceiling: if the maximum autoscaling or Serverless v2 ACU bound is set too low, a burst beyond it still throttles or slows down exactly like a statically undersized fleet would, so "serverless" is not a substitute for correctly setting that maximum, it only removes the need to pay for it when it is not in use.
Evaluate the trade-offs of using a managed multi-region database service (for example Cloud Spanner, Cosmos DB, or Aurora Global Database) versus running a self-managed sharded cluster on VMs or Kubernetes, for a system handling roughly 10 million QPS reads and 200,000 writes per second. Cover latency, consistency, operational complexity, cost, scaling behavior, and disaster-recovery capabilities, and give your recommendation.
Sample Answer
Direct answer
At 10 million reads per second and 200,000 writes per second, the default recommendation is a managed multi-region service (Spanner-class horizontal partitioning or Cosmos DB-class tunable consistency) over a self-managed sharded cluster, unless the team already operates comparable distributed stateful infrastructure in-house and the consistency requirements are loose enough to accept asynchronous cross-region replication. At this scale the operational surface a managed vendor absorbs, quorum health (whether enough replicas are up and agreeing to keep accepting writes), rebalancing, and cross-region failover (automatically switching traffic to a healthy region if one goes down) across what turns out to be hundreds of nodes, is exactly the class of problem these services are purpose-built for. The worked example and framework below show why, and name what would flip the recommendation.
Framework: six axes
| Axis | Managed multi-region (for example Cloud Spanner, Cosmos DB, Aurora Global Database) | Self-managed sharded cluster (VMs or Kubernetes) |
|---|---|---|
| Latency | In-region reads and writes stay low: Cosmos DB's own documentation guarantees a 99th-percentile (P99) latency under 10 ms for reads and writes within a region, at any consistency level. Cross-region strong consistency is bounded by physics, not engineering: Cosmos DB states cross-region strong-consistency write latency as two times the round-trip time (RTT) between the two farthest regions, plus 10 ms P99. | Fully tunable: keep the write quorum inside one metro region for low latency, and replicate elsewhere asynchronously for disaster recovery (DR) only, if the business can accept that. Requires the team to design and prove this topology correct itself. |
| Consistency | Comes largely built in. Cosmos DB offers five levels (Strong, Bounded Staleness, Session, Consistent Prefix, Eventual). Spanner gives a single strong guarantee, external consistency (global linearizability, meaning all observers agree on the order transactions actually committed in), via TrueTime, a globally synchronized clock with a bounded uncertainty window that every commit waits out before acknowledging. | Owned entirely by the team. Single-shard transactions are ordinary single-node ACID (atomicity, consistency, isolation, durability). Cross-shard transactions need a distributed-transaction layer, for example two-phase commit (a protocol that coordinates an atomic commit across multiple shards), that the team designs, implements, and must prove correct under partition and retry. |
| Operational complexity | Patching, quorum membership, internal rebalancing, and backup mechanics are the vendor's job. The team owns schema design, indexing, provisioned or consumed throughput sizing, and query-level tuning. | Everything: failover automation, connection pooling and proxy layers, monitoring, and on-call runbooks for partition and quorum-loss scenarios are the team's to write and operate, with no vendor site reliability engineering (SRE) team absorbing pages. |
| Cost | Priced at a premium over commodity compute (consumption-based request units, or per-node or per-vCPU list pricing depending on the specific service and tier; check the current pricing page for the exact service and region before budgeting, since list prices change without a fixed schedule). The premium buys engineering time the team does not have to spend building the same capability. | Commodity VM or Kubernetes compute, storage, and network egress rates, but the true cost includes the engineering headcount to build and operate the sharding, failover, and DR tooling a managed service ships by default. That cost does not appear on the cloud bill. |
| Scaling behavior | Elastic and mostly automatic. Aurora Global Database adds up to 10 read-only secondary regions with storage-based replication typically under a second of lag, though only the primary region accepts direct writes (a "write forwarding" feature lets secondaries relay writes to the primary, at the cost of that round trip). Spanner and Cosmos DB partition writes horizontally across internal shards transparently to the application. | Fully within the team's control (shard key choice, resharding strategy, instance sizing), but every reshard is a project the team runs and risks itself, exactly the work automatic rebalancing would otherwise absorb. |
| Disaster recovery | Documented, tested guarantees. A Cloud Spanner multi-region configuration places two read-write regions (two replicas each) plus a witness region (a fifth voting replica that participates in the write quorum but does not serve reads), five voting replicas total; a write quorum needs the leader region's replica plus any two of the other four, so the configuration survives the complete loss of any one region with zero data loss, a recovery point objective (RPO) of zero. Aurora Global Database offers a planned switchover (no data loss) and an unplanned failover after a regional outage (a small, non-zero RPO bounded by the sub-second replication lag (the delay between a write completing in the primary region and arriving in the secondary) at the moment of failure). | Fully bespoke: cross-region async replication, backup and restore, or a warm standby are all buildable, but the recovery time objective (RTO) and RPO the system actually delivers are only as good as the team's own runbook and the disaster tests actually run, not a documented product guarantee. |
Worked example
Whichever path is chosen, the raw infrastructure needed at this scale is a useful reality check: 10 million reads/sec and 200,000 writes/sec is real online transaction processing (OLTP) hardware regardless of who operates it.
import math
# Inputs: the QPS figures come from the question; the rest are stated,
# illustrative capacity-planning assumptions (NOT vendor-measured benchmarks).
read_qps = 10_000_000
write_qps = 200_000
read_capacity_per_node = 50_000 # assumed sustained cached-read throughput of one well-provisioned OLTP node
write_capacity_per_shard = 8_000 # assumed sustained write throughput of one shard's single-writer primary
dr_regions = 3 # regions in the deployment
shards_needed = math.ceil(write_qps / write_capacity_per_shard)
total_read_nodes = math.ceil(read_qps / read_capacity_per_node)
read_nodes_per_shard = math.ceil(total_read_nodes / shards_needed)
nodes_per_shard_group = 1 + read_nodes_per_shard # 1 primary + its read nodes
total_nodes_single_region = shards_needed * nodes_per_shard_group
total_nodes_all_regions = total_nodes_single_region * dr_regions
print(f"shards needed (write-bound): {write_qps:,} / {write_capacity_per_shard:,} -> {shards_needed}")
print(f"read-serving nodes needed (read-bound): {read_qps:,} / {read_capacity_per_node:,} -> {total_read_nodes}")
print(f"read nodes per shard: {total_read_nodes} / {shards_needed} -> {read_nodes_per_shard}")
print(f"nodes per shard group (1 primary + reads): {nodes_per_shard_group}")
print(f"total nodes, single region: {shards_needed} x {nodes_per_shard_group} -> {total_nodes_single_region}")
print(f"total nodes, {dr_regions}-region deployment: {total_nodes_single_region} x {dr_regions} -> {total_nodes_all_regions}")
Output:
shards needed (write-bound): 200,000 / 8,000 -> 25
read-serving nodes needed (read-bound): 10,000,000 / 50,000 -> 200
read nodes per shard: 200 / 25 -> 8
nodes per shard group (1 primary + reads): 9
total nodes, single region: 25 x 9 -> 225
total nodes, 3-region deployment: 225 x 3 -> 675
Roughly 675 stateful nodes across three regions, on these stated assumptions. That number does not change based on who manages it: a managed multi-region service still provisions and rebalances something in that range internally, it simply does not page the team when a node in it fails. The real question is whether the team wants to own the failure domain for 675 stateful nodes directly, given that a self-managed cluster at this size effectively requires building an internal SRE function for exactly that fleet.
flowchart LR
subgraph MG["Managed multi-region service"]
C1["Client"] --> R1["Regional endpoint"]
R1 --> P1[("Primary region")]
P1 -. replicates .-> S1[("Secondary region A")]
P1 -. replicates .-> S2[("Secondary region B")]
end
subgraph SM["Self-managed sharded cluster"]
C2["Client"] --> RT["Shard router"]
RT --> SH1[("Shard 1 primary")]
RT --> SH2[("Shard 2 primary")]
SH1 --> RE1[("Shard 1 replica")]
SH2 --> RE2[("Shard 2 replica")]
end
In the managed topology, the vendor owns everything to the right of the regional endpoint: which replica leads, how replication and quorum work, how a lost region is detected and routed around. In the self-managed topology, the team owns and must operate the shard router, the primary and replica wiring per shard, and the logic for what happens when a shard's primary disappears.
Recommendation and what would flip it
Recommend the managed multi-region path by default at this scale. The deciding factors are the team's existing distributed-systems operational maturity (does it already run something like Vitess- or CockroachDB-class infrastructure at hundreds of nodes today), the actual consistency requirement (does the product need synchronous cross-region strong consistency, or would single-writer-per-shard with asynchronous DR replication genuinely be acceptable), and whether the cost delta at roughly 675 nodes' worth of infrastructure materially matters to the budget, since the managed premium multiplies across a large fleet at this scale rather than a handful of instances.
It flips to self-managed when all three line up: the team already operates comparable stateful infrastructure in-house, the workload tolerates a single-writer-per-shard model with asynchronous cross-region replication instead of synchronous strong consistency, and the cost savings at this node count are large enough to justify paying the engineering-time cost once, building the sharding, failover, and DR tooling, instead of paying the managed-service premium every month indefinitely. Defaulting to "managed is always safer" ignores that at 675 nodes the managed premium is not a rounding error, and a team that already has the operational muscle for a fleet this size may reasonably prefer to keep that premium as engineering budget instead.
Trade-offs and pitfalls
The dominant failure mode on this kind of question is picking a side without naming the deciding variable, or hedging into "it depends" without ever committing. A second common mistake is assuming managed multi-region services give multi-region strong consistency for free: Cosmos DB explicitly does not support strong consistency on a multi-region-write account, and even Spanner's external consistency costs real latency, a bounded commit-wait on every write, it is not free ordering. A third is treating "self-managed" as automatically cheaper: at 675 nodes, the engineering cost of building and operating correct distributed-transaction and failover logic in-house is usually larger, not smaller, than the managed premium, unless that capability already exists in the organization.
A vendor offers a managed distributed SQL database that promises automatic sharding and rebalancing. List 6 operational questions you would ask before adopting it for a latency-sensitive transactional service.
Sample Answer
Direct answer
Six questions cover the ground a "handles sharding and rebalancing automatically" pitch conveniently skips: what latency the vendor will actually guarantee under your transaction shape, whether rebalancing degrades live traffic or pauses it, what the replication and consistency model implies for data loss and recovery time, how visible internal topology changes are to your own monitoring, how the system behaves when it cannot reach a quorum (a majority of replicas agreeing before a write counts as durable), and how hard it would be to leave. Ask all six framed against "latency-sensitive transactional," not as a generic vendor-diligence checklist: an answer that would satisfy an analytics workload can still be a bad fit here.
The six questions
| # | Question | Why it matters for a latency-sensitive transactional workload | Red flag in the vendor's answer |
|---|---|---|---|
| 1. Latency guarantee and measurement basis | "What 99th-percentile (P99) commit latency do you guarantee for a single-row transactional write, under a documented workload similar to mine, and is that backed by a service-level agreement (SLA) with a financial remedy?" | Distributed SQL databases add a consensus round trip (a network exchange where a quorum of replicas must acknowledge a write) on every commit. The number that matters is the tail latency of a small, single-row transaction, not an average and not a number measured on a large analytical batch. | Vendor quotes only mean or median latency, or a benchmark run on multi-row batch writes instead of the small single-row commits typical of a transactional service. |
| 2. Rebalancing impact on live traffic | "When the cluster rebalances automatically (a node joins, a hot shard splits, a failed replica is repaired), does the affected data stay fully read and write available, or does the system pause or throttle traffic on the piece being moved? Can rebalancing be rate-limited or scheduled away from peak hours?" | Rebalancing moves a shard (a contiguous chunk of the table's rows, grouped by key range) from one node to another by streaming a full copy of it across the network. Left unthrottled, that transfer competes with production traffic for network and CPU capacity right when the cluster's internal state is least predictable. This is not hypothetical: even mature distributed SQL engines have shipped rebalancing paths where an ordinary configuration change measurably degraded foreground query latency before the vendor patched it. | Vendor cannot describe a concrete rate-limiting or scheduling mechanism, or only offers "it is usually fine in practice." |
| 3. Replication, consistency, and disaster-recovery implications | "What is the default replication factor and quorum size per shard, what consistency guarantee does a client get by default (strict ordering across all replicas versus eventual convergence), and what recovery point objective (RPO, how much recent data could be lost) and recovery time objective (RTO, how long recovery takes) does that imply if a region fails mid-transaction?" | "Automatic sharding" says nothing about whether each shard's replicas live in one region (fast, but a regional outage can lose recent writes) or are kept in sync across regions by a global consensus protocol (safer, but adds real latency to every commit). | Vendor cannot state RPO or RTO as numbers, or uses "highly available" and "zero data loss" interchangeably. |
| 4. Observability into internal topology changes | "What real-time visibility exists into shard splits, leader elections (which replica currently owns the right to accept writes for a shard), and in-progress rebalancing, and can a latency spike in my own application performance monitoring (APM) tooling be correlated back to a specific internal event?" | If the database's internal reshuffling is invisible, a 2 a.m. latency spike looks identical to an application bug, and an on-call engineer burns an hour ruling out their own code before learning the database moved a shard underneath them. | Vendor offers only an aggregate cluster-health dashboard with no exportable, timestamped events for splits, elections, or rebalances. |
| 5. Failure-mode behavior | "During a network partition or a quorum loss on a shard, does the system fail closed (refuse writes, to stay consistent) or fail open (keep accepting writes on a stale replica)? Does failover for a lost leader happen automatically, or does it require a manual runbook step?" | For a transactional service, a database that fails open during a partition can accept writes that conflict or silently overwrite each other, surfacing as corrupted business state days later. That is worse than a short, honest availability gap. | Vendor cannot describe the failure mode precisely, or the answer implies writes are accepted during a partition "to keep availability high." |
| 6. Data portability and exit strategy | "If the contract ends, is export a native logical dump, a wire-protocol-compatible export another engine can read, or a proprietary snapshot only the vendor's own restore tooling understands? Who controls the encryption keys, and how long would extracting the full current data volume take at the vendor's stated export throughput?" | Automatic sharding and rebalancing are exactly the features that make a vendor's on-disk storage format the least portable. Verifying the exit path before signing is far cheaper than discovering it during a forced migration. | Vendor's export path is undocumented, or only supports restoring into their own product. |
Worked example
Take a payments authorization service: 3,000 transactions per second, a 40 ms P99 commit latency SLA of its own, and a requirement to survive a full region outage, so the team is evaluating a three-region deployment spanning, say, New York and San Francisco.
Question 1 asks the vendor for a P99 commit latency guarantee. Before even hearing their number, it is worth computing the physics floor a synchronous cross-region quorum write cannot beat, because no amount of engineering can get a commit acknowledgment back faster than light travels through fiber:
# Physics floor on cross-region consensus commit latency: a sanity check on any
# vendor SLA number, not a benchmark. All inputs are stated explicitly below.
great_circle_km = 4130 # approx. New York <-> San Francisco great-circle distance
routing_factor = 1.5 # real fiber paths run longer than the great circle
fiber_path_km = great_circle_km * routing_factor
speed_of_light_vacuum_km_s = 299_792
refractive_index_fiber = 1.5 # typical single-mode fiber
speed_in_fiber_km_s = speed_of_light_vacuum_km_s / refractive_index_fiber
one_way_ms = (fiber_path_km / speed_in_fiber_km_s) * 1000
round_trip_ms = one_way_ms * 2
print(f"fiber path length: {great_circle_km} km x {routing_factor} = {fiber_path_km:.0f} km")
print(f"speed in fiber: {speed_of_light_vacuum_km_s} / {refractive_index_fiber} = {speed_in_fiber_km_s:,.0f} km/s")
print(f"one-way propagation time: {fiber_path_km:.0f} km / {speed_in_fiber_km_s:,.0f} km/s = {one_way_ms:.3f} ms")
print(f"round trip (quorum ack floor): {one_way_ms:.3f} ms x 2 = {round_trip_ms:.2f} ms")
Output:
fiber path length: 4130 km x 1.5 = 6195 km
speed in fiber: 299792 / 1.5 = 199,861 km/s
one-way propagation time: 6195 km / 199,861 km/s = 30.996 ms
round trip (quorum ack floor): 30.996 ms x 2 = 61.99 ms
A round trip between New York and San Francisco alone costs about 62 ms, before any disk write, queueing, or server-side processing. If the vendor's answer to question 1 is "P99 commit latency under 40 ms" and question 3 reveals that every commit needs a quorum acknowledgment from a replica in the other region, those two answers contradict each other: the deployment cannot meet its own stated SLA. The honest fix is either to keep the write quorum inside one metro region (propagation delay measured in fractions of a millisecond) and replicate to the far region asynchronously for disaster recovery only, accepting a small, named RPO, or to relax the latency SLA. Either is a legitimate design choice; a vendor who does not surface this tension when questions 1 and 3 are asked together has not actually answered the question.
Trade-offs and pitfalls
The most common wrong turn is accepting a vendor's self-reported questionnaire as verification. A "yes" to all six questions from a sales engineer is not evidence: insist on a proof-of-concept load test that replays the actual read/write mix and transaction size against the vendor's cluster, sized to the real data volume, while watching P99 latency through a real rebalance (add a node, kill a replica, and observe). "Distributed" and "managed" are not synonyms for "safe for latency-critical transactions": consensus overhead, rebalancing behavior, and failure-mode defaults vary enormously between vendors, and that is exactly the corner of the evaluation a generic due-diligence checklist glosses over.
Explain read replicas in managed database offerings: what they are, how they work in services like Amazon RDS/Aurora or Cloud SQL, what operational problems they solve, and what limitations or risks you'd want to watch for when relying on them.
Sample Answer
A read replica is an asynchronous, read-only copy of a primary database. The primary streams its stream of committed changes (the binary log in MySQL, the write-ahead log, or WAL, in PostgreSQL) to one or more replicas, which replay those changes to stay current. The replica accepts read queries but never writes, and it is always at least slightly behind the primary because replication is asynchronous: the primary does not wait for the replica before acknowledging a write.
How it works in managed offerings
- Amazon RDS (MySQL/PostgreSQL/MariaDB): uses the engine's own native replication mechanism, binlog-based for MySQL/MariaDB, WAL streaming for PostgreSQL, to ship changes to up to several read replicas per primary. Each replica is a fully separate instance with its own storage and its own endpoint.
- Amazon Aurora: replicas share the same underlying cluster storage volume as the writer instead of copying data over the network, so replica lag is typically much lower than RDS's engine-native replication under normal load, low enough that AWS markets Aurora's replicas as "low-latency." Aurora also lets a replica be promoted automatically as part of Multi-AZ failover (Multi-AZ means the provider keeps a synchronized standby copy of the database in a second availability zone; failover is automatically switching traffic to that standby, or here, to a promoted replica, when the primary fails), which RDS's plain read replicas cannot do.
- Google Cloud SQL: replicates asynchronously per-transaction from the primary to one or more read replicas, including optional cross-region replicas, using the same engine-native mechanisms under the hood.
In all three, the replica is provisioned and monitored by the provider (you don't manage the replication process by hand), but the replication itself is still asynchronous and lag is not bounded to zero.
What problems read replicas solve
- Read scaling: route SELECT-heavy traffic to one or more replicas so it does not compete with writes for CPU and I/O on the primary.
- Workload isolation: point a specific class of query, for example an analytics dashboard or a nightly reporting job, at a dedicated replica so a slow or expensive query can't degrade the primary's write latency.
- Reduced primary load and latency: fewer connections and less query volume on the primary generally means more headroom and lower p95/p99 latency (the response time for the slowest 5% and slowest 1% of requests, a way of measuring worst-case performance rather than the average) for the writes and reads that must hit the primary.
- A promotable target: an RDS read replica (not a Multi-AZ standby) can be manually promoted to a standalone writable instance, which is useful for cross-region disaster recovery or for splitting off a subset of traffic to its own database.
Limitations and risks to watch
- Replication lag is not bounded. Under normal load it can be small enough to ignore; under a write burst, a long-running DDL (data definition language, for example an ALTER TABLE) statement, or a large batch job on the primary, it can grow to seconds or minutes, and the replica has no way to signal "I'm behind" to a client unless you build that check yourself.
- Eventual consistency, not read-your-writes. A client that writes to the primary and immediately reads from a replica can see stale data, or even see the write "disappear" if it lands on a replica that hasn't caught up yet. This is the single most common production bug with read replicas: a user submits a form, the confirmation page reads from a replica, and the user's own just-written data appears missing.
- No cross-replica consistency guarantee. Two replicas of the same primary can be at different points in the replication stream at the same instant, so two requests hitting different replicas can see different, mutually inconsistent snapshots.
- Promotion is a manual, disruptive operation, not an automatic failover mechanism. Promoting a read replica breaks its replication link permanently, and every other reader and writer in the application needs to be repointed. This is a materially different (and slower) recovery path than a Multi-AZ standby failover.
- Real added cost. A read replica is a full running instance, not a lightweight cache, so it roughly multiplies your compute bill by the number of replicas you run.
Worked example: how a write burst turns into visible lag
Assume a primary normally emits 12 MB/s of write-ahead log under steady state, a replica can apply changes at 20 MB/s, and a 10-minute batch job pushes the primary's write rate to 30 MB/s.
backlog growth rate during burst=30−20=10 MB/sOver the 600-second burst that backlog reaches 10×600=6,000 MB of unreplayed write-ahead log sitting on the replica the instant the burst ends.
It is tempting to convert that 6,000 MB straight into a "seconds behind" figure by dividing by the replica's apply rate (6,000 / 20 = 300 seconds), but that is not the number a real replication-lag metric would show at that instant, and it is a common mistake when reasoning about replication under load. What tools like MySQL's seconds_behind_master or Aurora/RDS's ReplicaLag CloudWatch metric actually report is how old the transaction the replica is currently replaying is, which you get by comparing cumulative bytes applied against cumulative bytes produced, not backlog divided by capacity. At the moment the burst ends (600 seconds in), the replica has applied 20×600=12,000 MB while the primary has produced 30×600=18,000 MB since the burst started. The 12,000 MB the replica has applied so far is data the primary had already produced after just 12,000/30=400 seconds of the burst, so the replica is 600−400=200 seconds, about 3 minutes 20 seconds, behind at the instant the burst ends, not 300 seconds.
Lag keeps growing for a while even after the burst is over, because the replica is still capacity-constrained at 20 MB/s working through the backlog while the primary keeps producing new data (now at the lower 12 MB/s rate) that pushes "how old is what I'm applying right now" further out. Lag peaks about 5 minutes after the burst ends, at 300 seconds (5 minutes) behind, then shrinks back toward zero as the replica keeps applying at 20 MB/s against a primary now producing only 12 MB/s, a net drain rate of 20−12=8 MB/s. The 6,000 MB backlog itself (still sitting there right when the burst ends) fully drains 6,000/8=750 seconds, 12.5 minutes, after the burst ends, which is also when lag finally returns to zero.
Total elapsed time with a nonzero backlog and elevated lag: the 600-second burst plus the 750-second drain, 1,350 seconds, 22.5 minutes, not the 17.5 minutes you get from naively adding a 300-second instant-lag figure to the drain time. Lag grows for the first 900 seconds (15 minutes: the full 10-minute burst plus 5 more minutes while the primary is still outpacing the still-catching-up replica), peaks at 5 minutes behind, then shrinks over the remaining 450 seconds (7.5 minutes). For that whole 22.5-minute window, anything reading from that replica was looking at data that was seconds to minutes old. This is exactly the kind of window where a "read after write" bug shows up, and it is why replica lag needs to be an explicit, monitored metric (RDS and Aurora both expose it as a CloudWatch metric) rather than an assumption, or worse, a hand calculation done wrong under incident pressure.
Unlock Full Question Bank
Get access to all 14 Cloud and Managed Database Services interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.