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.
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.
You are evaluating three workloads and must recommend either a managed relational or a managed NoSQL/data service. Workloads:
A) Payment processing with complex joins, strong transactional integrity, and strict consistency.
B) User profile store with flexible schema, extremely high read scale, and fast reads (p95 < 50ms).
C) IoT telemetry ingestion with massive write throughput, time-series data, and eventual consistency acceptable.
For each workload recommend a managed product (e.g., RDS PostgreSQL, Aurora, DynamoDB, Cloud Spanner), justify your choice, and note the operational considerations you'd need to handle for the chosen service.
Sample Answer
These three workloads sit at genuinely different points on the relational-versus-NoSQL spectrum, and the right call is: managed relational (Aurora PostgreSQL, AWS's own PostgreSQL-compatible managed database) for payments, DynamoDB (AWS's managed NoSQL key-value and document database) for the profile store, and DynamoDB for telemetry ingestion, but for different reasons in each case, since "high write throughput" and "high read throughput" are solved by the same product through different design choices.
Workload A: payment processing, complex joins, strict consistency
Recommendation: Amazon Aurora PostgreSQL (Multi-AZ). Complex joins and strong transactional integrity are exactly what a relational engine with full ACID (atomicity, consistency, isolation, durability) transaction support is built for: multi-table updates (debit one account, credit another, write a ledger row) either all commit or none do, and foreign keys enforce referential integrity the database itself checks. Aurora over plain RDS mainly for its storage-layer replication (faster, more resilient failover (automatically switching to a healthy standby when the primary fails) than RDS's engine-level replication) and higher I/O ceiling if transaction volume grows.
Operational considerations: enable Multi-AZ so a failover does not lose committed transactions; put RDS Proxy in front of it since payment services tend to run many short transactions from many application instances, and connection exhaustion is a common self-inflicted outage; enable encryption at rest and enforce TLS (rds.force_ssl) since this is regulated financial data; test schema migrations against lock behavior specifically, since an ALTER TABLE that takes an exclusive lock on a hot payments table during business hours is a self-inflicted outage separate from any database limitation; enable audit logging for compliance (PCI DSS, payment card industry data security standard) and test point-in-time recovery, not just confirm backups exist.
Workload B: user profile store, flexible schema, extreme read scale, p95 < 50ms
Recommendation: DynamoDB, with DAX (DynamoDB Accelerator, an in-memory read cache) in front. A profile store is a keyed lookup (get this user's profile) with a schema that varies per user and grows new attributes over time without a migration, which is DynamoDB's core strength, and its single-digit-millisecond baseline latency, extended to sub-millisecond with DAX, comfortably clears a 50ms p95 target.
Operational considerations: partition key on user_id for even distribution; add global secondary indexes (GSIs) sparingly and only for real query patterns (for example lookup by email for login), since each GSI is its own separately-throughput-provisioned structure; choose on-demand capacity mode unless traffic is genuinely steady and predictable enough that provisioned throughput with auto scaling is worth the operational tuning; monitor DAX cache hit rate, since a low hit rate means the read load is really landing on the table and the latency budget assumption is wrong.
Workload C: IoT telemetry ingestion, massive write throughput, time-series, eventual consistency acceptable
Recommendation: DynamoDB, partitioned by device_id with a sort key of timestamp (or a time-bucketed composite like device_id#hour), with time-to-live (TTL) enabled to auto-expire old telemetry rather than manually deleting it. Massive write throughput with eventual consistency acceptable is a bad fit for a relational engine's transactional write path but a good fit for DynamoDB's partition-parallel write model, where throughput scales by adding partitions rather than by scaling up a single writer.
Operational considerations: watch for a hot partition on any single very chatty device or on a shared time bucket if many devices write to the same minute-level key, and shard the key (a suffix like device_id#shard_n) if a single device's write rate alone could approach the per-partition write ceiling; use on-demand capacity mode given IoT fleets are rarely perfectly predictable (device rollouts, firmware updates causing retry storms); if the dominant read pattern later turns out to be time-range aggregation across many devices (dashboards, anomaly detection) rather than per-device lookups, stream changes out via DynamoDB Streams into a purpose-built time-series or analytics store (for example Amazon Timestream, or S3 plus a query engine) rather than trying to make DynamoDB itself do wide time-range scans, which it is not optimized for.
Worked example: why the same product needs different partition-key designs
# Workload B (profile store): key by the entity you look up directly
PK = user_id # e.g. "user#48213" -> one item, fast point read
# Workload C (telemetry): key to spread write load across time AND devices
PK = f"{device_id}#{hour_bucket}" # e.g. "sensor-9921#2026-09-24T14" -> bounds any
SK = timestamp # single partition's write rate to one device-hour
Both are DynamoDB tables, but workload B's key exists to make a single, specific item cheap to find, while workload C's key exists to prevent any one device or time window from concentrating write throughput onto a single partition. Recommending "DynamoDB" for both workloads is only half the decision; the partition key design is the other half, and getting it wrong reproduces the exact hot-partition and throttling problems a relational engine would not have had in the first place.
Trade-offs and pitfalls
- Recommending DynamoDB for both B and C is not "the same answer twice": the schemas, partition-key strategies, and even the capacity mode choice differ, and a candidate who says "DynamoDB" without describing how the key design differs has not actually answered the question.
- Aurora PostgreSQL for payments is the safer default, but if this system needed to scale writes globally with strong consistency across regions, Cloud Spanner would be the named alternative worth mentioning: it gives horizontal write scale with external consistency (a stronger guarantee than most distributed databases provide: transactions are ordered by real wall-clock time across every region, so if one transaction finishes in real time before another starts, every reader sees them in that same order, not just eventually), at the cost of a different query and schema model (interleaved tables, where a child table's rows are physically stored next to their parent row so the relationship is declared up front rather than expressed only through foreign keys and joins; no traditional single-writer failover story either) and meaningfully higher operational and cost complexity than a single-region Aurora cluster. For a workload described only as "payment processing with complex joins," that additional complexity is not yet justified.
- Do not pick DynamoDB for workload A just because it is "the managed NoSQL option and the question offers a choice." Strict consistency across multiple related writes (the actual requirement stated) is not what DynamoDB's item-level atomicity model is built for; DynamoDB transactions exist but are more limited and more expensive per operation than a relational engine's native transaction support, and multi-table joins have no equivalent at all.
You need to migrate an RDS instance from single-AZ to multi-AZ with minimal downtime. Describe a Terraform-driven plan and code snippets to perform this migration safely, including prechecks, snapshot or replica creation, promotion strategy, and rollback options. Explain limitations of automation and how to validate the migration.
Sample Answer
Approach
Converting single-AZ to Multi-AZ is a modify-db-instance operation: AWS automatically provisions a new standby DB instance in a second availability zone (AZ) and establishes it as a synchronous replica of the primary, without you creating or managing that standby as a separate resource. Provisioning and initially populating that standby is real work proportional to data size, which is why this is a background operation with a real duration, not an instant flag flip. The direct Terraform path is flipping multi_az on the existing aws_db_instance resource; there is an older, more manual alternative (create a read replica yourself, promote it, then re-establish Multi-AZ on the promoted instance) worth naming because it is still sometimes the right tool, but it involves a real cutover and more moving parts, so the direct path is the recommendation here unless a specific constraint rules it out.
Prechecks (before touching multi_az)
- Backups must be enabled. Multi-AZ requires automated backups on (a non-zero backup retention period); if backups are currently off, turn that on first, as its own isolated change, so it is not conflated with the Multi-AZ conversion if something goes wrong.
- The DB subnet group must already span at least two AZs. This is the most common real blocker: Multi-AZ needs a second AZ with an available subnet in the instance's subnet group, and if the environment was built assuming single-AZ, that subnet may simply not exist yet.
- Option group compatibility. Some engine-specific options are incompatible with Multi-AZ, so the current option group needs a check against the target engine's Multi-AZ restrictions before applying.
- Confirm the maintenance window and
apply_immediatelychoice deliberately. This is a change worth applying in a chosen window, not reflexively immediately, given the AZ standby's initial sync work.
Terraform-driven plan
# Precheck as code: fail plan/apply if the subnet group doesn't already span >= 2 AZs,
# rather than discovering that when the RDS (Amazon Relational Database Service) API rejects the change.
# The "data" blocks below read information about existing AWS resources; they create nothing.
# The null_resource further down creates no real AWS resource either: it exists purely as a place
# to attach the lifecycle/precondition check to, Terraform's built-in way to fail early with a clear
# error message if a condition isn't met, before anything is actually changed.
data "aws_subnet" "db_subnets" {
for_each = toset(data.aws_db_subnet_group.this.subnet_ids)
id = each.value
}
data "aws_db_subnet_group" "this" {
name = aws_db_instance.prod.db_subnet_group_name
}
locals {
distinct_azs = distinct([for s in data.aws_subnet.db_subnets : s.availability_zone])
}
resource "null_resource" "az_precheck" {
# This resource creates nothing in AWS; it only hosts the precondition check below.
lifecycle {
precondition {
condition = length(local.distinct_azs) >= 2
error_message = "DB subnet group only spans ${length(local.distinct_azs)} AZ(s); Multi-AZ needs at least 2."
}
}
}
resource "aws_db_instance" "prod" {
identifier = "prod-webapp-db"
# ... existing engine / instance_class / storage arguments unchanged ...
backup_retention_period = 7 # was already >0; Multi-AZ requires this
multi_az = true # was false: the actual conversion
apply_immediately = false # land it in the next maintenance window, not now
timeouts {
update = "90m" # a large data volume's initial standby sync can exceed the provider default
}
}
Promotion strategy
The direct route above needs no promotion step: AWS creates and syncs the standby internally and exposes it only as the SecondaryAvailabilityZone field on the same instance, not as a resource you manage or cut over to yourself. The alternate manual pattern, worth knowing but not the default recommendation, is to create a read replica in a second AZ (aws_db_instance with replicate_source_db set), promote it to a standalone writable instance during a maintenance window (removing replicate_source_db, which triggers promotion), and enable Multi-AZ on the promoted instance. That path involves an explicit cutover with real downtime risk and is generally worse for a same-region HA conversion than the direct multi_az = true change; it earns its complexity only when the direct conversion is blocked by something the prechecks above cannot fix in place (for example, needing to also change the engine major version at the same time).
Rollback options
The reverse change is symmetric and low-risk: set multi_az = false and apply. This removes the standby but leaves the primary and its data untouched, since the primary was never the thing being modified. Two things a rollback does not undo: the small, permanent increase in write and commit latency Multi-AZ introduces reverts along with the standby, so rollback is a real fix if the latency change itself is the problem, and rollback has no read-traffic implication either way, since a Multi-AZ single-standby deployment never serves reads from the standby to begin with (unlike a read replica or a Multi-AZ DB cluster). If the conversion is still in progress when a rollback is needed, wait for it to reach a stable available state first: reversing a change mid-flight is not a documented, supported path, and attempting it risks leaving the instance in an inconsistent modification state rather than cleanly reverting.
Limitations of automation
Terraform expresses the desired end state (multi_az = true); it does not observe or control AWS's internal orchestration between accepting that change and the instance actually reaching a stable available status with a populated standby. terraform apply returns once its polling loop sees the instance return to available, which for a large database can take meaningfully longer than the provider's default timeout, hence setting timeouts.update explicitly above rather than trusting the default. Terraform also cannot validate application-level readiness: whether the app's connection pool (its cache of reusable open database connections) and any read/write-splitting logic behave correctly once a standby exists is not something terraform plan or apply can tell you, and has to be validated separately, described below.
Validating the migration
aws rds describe-db-instances --db-instance-identifier prod-webapp-db \
--query "DBInstances[0].{MultiAZ:MultiAZ,SecondaryAZ:SecondaryAvailabilityZone}"
# {"MultiAZ": true, "SecondaryAZ": "us-east-1b"}
A populated SecondaryAZ value, not just MultiAZ: true, is the real proof a standby exists and is attached; the boolean alone confirms the setting was accepted, not that the standby finished syncing. Before trusting this in production, force a real failover on a non-production copy with aws rds reboot-db-instance --db-instance-identifier <copy> --force-failover and measure how long the application actually takes to reconnect, which is the real end-to-end validation, not just the RDS-reported failover time. After the change lands in production, expect a small, real increase in write and commit latency from here forward: AWS documents that Multi-AZ DB instance deployments can have higher write and commit latency than single-AZ, from the synchronous replication itself, so a modest, steady latency increase is the expected cost of the durability gained, not a regression to chase.
Key points
- The conversion itself is a background operation and does not require stopping the instance, but it is not free: it does real sync work proportional to data size, and it introduces a small, permanent increase in write latency from then on, the ongoing cost of synchronous replication.
- Prechecks (subnet AZ coverage, backups enabled, option group compatibility) catch the failures that would otherwise surface as an opaque API rejection mid-change.
- Validate with the populated
SecondaryAZfield and, ideally, an actual forced-failover test on a non-production copy, not just a green Terraform apply.
Edge cases
- A DB subnet group that only has subnets in one AZ: the apply fails at the precondition (or, without it, at the AWS API) rather than partially applying.
- Automated backups disabled: fold that into its own prior change so it is not silently bundled with the Multi-AZ change if either one needs to be rolled back independently.
- Applying during a period of heavy write load extends the standby's initial sync time and, correspondingly, the window during which the new write-latency overhead is compounded with catch-up replication traffic; scheduling this for a genuinely low-traffic window matters more for a large, busy database than for a small one.
- An option group with a Multi-AZ-incompatible setting only surfaces as a rejection at apply time unless it was checked in the precheck step; treat the precheck list as mandatory, not optional, precisely because the failure mode otherwise looks identical to a generic API error with no obvious cause.
Explain what a managed database service is, and describe the primary trade-offs of using one (for example Amazon RDS/Aurora, Cloud SQL, DynamoDB) compared to self-hosting a database. For each trade-off, say what the cloud provider takes on and what stays the team's job, and give one concrete example of a choice that materially affected reliability or cost.
Sample Answer
A managed database service is one where the cloud provider operates the database engine on your behalf: it provisions the compute and storage, patches the host operating system and engine, runs automated backups, handles hardware failure and (if you turn it on) failover (automatically switching traffic to a healthy standby when the primary fails), and exposes a connection endpoint plus a control plane API instead of shell access to a box. Amazon RDS/Aurora and Google Cloud SQL are managed relational database services (structured tables, SQL, joins), while DynamoDB is a managed NoSQL key-value store (no fixed schema, no joins, items looked up by key), a fundamentally different kind of database. All three still count as "managed" in the sense used here: the provider operates the engine so your team doesn't have to. The core trade-off is that you give up low-level control (custom kernel tuning, exotic extensions, root access) in exchange for offloading undifferentiated operational work, at a price premium, and with the provider dictating the maintenance windows and upgrade cadence you have to plan around.
What the provider takes on vs. what stays your job
| Responsibility | Provider (managed service) | Still your job |
|---|---|---|
| Physical hardware, host OS patching | Yes | No |
| Engine minor-version patching | Yes, applied in a maintenance window | Choosing that window and testing compatibility first |
| Automated backups / snapshots | Yes, taken on a schedule | Verifying you can actually restore to your target recovery point objective (RPO), and testing that restore |
| High availability / failover orchestration | Yes, if you provision it (for example RDS Multi-AZ) | Deciding whether to pay for it, and making the app reconnect cleanly after a failover |
| Storage durability | Yes | Choosing storage type, size, and IOPS (input/output operations per second) for the workload |
| Schema design, indexing, query tuning | No | Entirely yours |
| Connection management | No | Pooling, sizing max connections, avoiding connection storms |
| Capacity planning / instance sizing | No | Entirely yours |
| Encryption mechanics (turning it on, managing keys) | Yes, once requested | Key policy, network exposure, credential rotation |
| Cost | You pay for the abstraction | Rightsizing and ongoing cost control are still yours |
The one-line version: the provider owns keeping the box alive. Your team still owns making the database correct, fast, and affordable for your specific workload. Nothing about "managed" removes the need for someone who understands query plans, isolation levels, or the data model.
Worked example: a concrete reliability and cost trade-off
A team running Amazon RDS for PostgreSQL decides against enabling Multi-AZ to save the roughly 2x compute cost of running a synchronous standby, reasoning that "RDS already takes automated backups, so we're covered." RDS's automated backups upload transaction logs to S3 (Amazon's object storage service) every 5 minutes, so in the single-AZ configuration the real RPO after an availability zone (AZ, an isolated data center within a cloud region) impairment is up to 5 minutes of lost writes, plus however long it takes to notice the instance is down and restore from the latest restorable point. The recovery time objective (RTO, how long recovery takes) is however long a full restore-from-snapshot takes for that data volume, easily tens of minutes for a large database. With Multi-AZ enabled, the standby is kept current by synchronous replication (the primary does not acknowledge a write until the standby has it too), so failover loses effectively no committed data, and AWS states that a Multi-AZ DB instance failover happens "as quickly as 60 seconds," with most failovers completing within one to two minutes. Skipping Multi-AZ was a deliberate cost/reliability trade: it saved money every month, but it converted "a few minutes of trouble" into "a real outage with real data loss" the one time an AZ actually failed. Neither choice is universally wrong: for a staging database that trade is probably fine; for the primary store behind checkout, it usually is not.
Trade-offs and pitfalls
- Managed does not mean hands-off. Query performance, index design, and data modeling determine most of what actually breaks in production, and none of that is automated away by the provider.
- "It's backed up" is not the same as "it meets our RPO." Point-in-time recovery from 5-minute log shipping is a materially weaker guarantee than a synchronous standby. Know which one you are actually relying on before an incident, not during one.
- Self-hosting keeps some levers a managed service takes away: custom compiled extensions, OS-level tuning (filesystem choice, kernel parameters), and full superuser access. If a workload genuinely needs one of those, that is a real reason to self-host, not just inertia.
- The cost model shifts from mostly fixed infrastructure and ops spend to a metered bill driven by instance size, storage, IOPS, and backup retention. A managed service can be cheaper than the fully loaded cost of an in-house operations team, or more expensive than a lean self-hosted setup at very large, steady scale. The crossover point depends on team size and existing operational maturity, not a universal rule.
Unlock Full Question Bank
Get access to all 20 Cloud and Managed Database Services interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.