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.
You are deciding whether to move the primary database to a serverless managed database or keep it on a self-managed cluster running on VMs or containers. Discuss the connection-scaling issues serverless callers create, the proxy patterns you would consider (for example connection pooling or RDS Proxy), cold-start interactions, cost elasticity, operational overhead, and migration complexity.
Sample Answer
Serverless callers break the assumption self-managed database sizing quietly relies on: that a bounded, known number of long-lived application processes hold a bounded, known number of connections. A serverless caller like AWS Lambda instead can spin up hundreds or thousands of short-lived execution environments during a burst, and neither a self-managed cluster's fixed max_connections nor a naively provisioned serverless database survives that without a connection proxy in the path. The recommendation: put a proxy (RDS Proxy, a self-run PgBouncer or PgCat in transaction mode, or Cloud SQL's connector) in front of the database and treat it as a required architectural component, not an optional extra, whichever database you choose; with that in place, a serverless-capable managed database wins over a self-managed cluster for this specific caller shape on every axis except raw steady-state infrastructure cost, which is rarely the deciding factor once the operational cost of getting connection scaling wrong is counted.
Why serverless callers exhaust connections
Each Lambda execution environment behaves like its own short-lived process. A warm environment can reuse a connection across invocations for as long as it stays alive, but a burst of traffic spins up many new environments simultaneously, and each one that opens its own database connection on cold start has no shared, persistent pool the way a long-running application server naturally has, one pool, shared across every request that server handles. The result is that concurrency at the compute layer translates almost one-to-one into concurrent connection demand at the database layer, a relationship a traditional fixed-process application server never creates in the first place.
Proxy-pattern mitigations
- RDS Proxy: sits between the application and RDS/Aurora, pools and multiplexes connections, and is the AWS-managed default for this pattern.
- PgBouncer or PgCat in transaction mode: the self-hosted equivalent for PostgreSQL, releasing the real database connection back to the pool the instant a transaction commits rather than holding it for a client's whole session.
- Cloud SQL Auth Proxy / connectors: the equivalent authenticated, pooled path for Cloud SQL.
All three convert "many short-lived execution environments each wanting a connection" into "a small, bounded number of real database connections," which is what actually lets a serverless caller survive a real traffic burst, regardless of whether the database itself is self-managed or serverless.
Cold-start interactions
Two separate cold starts can stack unfavorably: the caller's own cold start (a new Lambda execution environment initializing, which is also where its first database or proxy connection gets established) and, if the database side is also serverless with scale-to-zero enabled, the database's own resume-from-paused delay. A request that happens to hit both a cold caller and a paused database pays both penalties in sequence. For a workload built on serverless callers, the practical mitigation is to keep the database side warm, a non-zero minimum capacity rather than scale-to-zero, even though that gives up some of serverless's cost-elasticity benefit; the alternative is a compounding latency tail on exactly the requests that are already least predictable.
Cost elasticity and operational overhead
A serverless database paired with serverless callers gives the cleanest cost-tracks-actual-usage story, genuinely valuable for spiky or unpredictable traffic. A self-managed cluster on fixed virtual machines (VMs) has no elasticity at all: the provisioned cluster is paid for whether traffic shows up or not. But "serverless removes operational work" is only half true. Self-managed adds real, ongoing operational work (patching, high availability, backups) independent of the caller side; a serverless database removes most of that, but introduces a new, smaller operational surface that did not exist before: proxy capacity planning and monitoring, minimum-capacity and cold-start tuning, and a connection-storm incident response playbook for the cases the proxy does not fully absorb.
Migration complexity is not just an infrastructure change
Adopting this pattern typically requires application-side changes, not only new infrastructure:
- Connection timeout and retry logic has to change. A connection attempt might now be queued or briefly rejected by the proxy under load, instead of always succeeding immediately the way a warm pool on a long-running app server does, so retry-with-backoff logic that previously did not exist becomes necessary.
- Anything relying on session-level state breaks under transaction-mode pooling and has to be found and rewritten, not just reconfigured: prepared statements assumed to persist across calls, session variables, or advisory locks held across requests.
- Cutover needs the same phased, rollback-capable approach as any other production database change, not a configuration flag flip, since connection behavior under real burst load is exactly the kind of thing that is hard to fully validate outside production traffic.
Worked example: what the proxy is actually absorbing
proxy_db_side_pool = 50 # real database connections the proxy maintains
concurrent_lambda_burst = 500 # simultaneous execution environments during a spike
immediately_served = min(proxy_db_side_pool, concurrent_lambda_burst)
queued = max(0, concurrent_lambda_burst - proxy_db_side_pool)
print(f"Requests served immediately from the pool: {immediately_served}")
print(f"Requests queued at the proxy, waiting for a connection to free up: {queued}")
print(f"Fraction queued: {queued/concurrent_lambda_burst:.0%}")
Requests served immediately from the pool: 50
Requests queued at the proxy, waiting for a connection to free up: 450
Fraction queued: 90%
Without a proxy, a database with a hard connection ceiling near 50 would simply reject most of those 500 simultaneous connection attempts outright. With the proxy in front, 450 of them queue briefly instead, each waiting only as long as the transaction ahead of it in line takes, typically a short OLTP (online transaction processing) transaction. That difference, hard rejection versus a brief queue, is the entire value the proxy adds, and it is exactly what neither a bare self-managed cluster nor a bare serverless database provides on its own.
Trade-offs and pitfalls
- Treating the proxy as optional, "we'll add it if connections become a problem," is the most common mistake here: connection exhaustion under a real burst is a hard failure mode, not a gradual degradation, so it needs to be designed in up front, not bolted on after an incident.
- Keeping the database warm to avoid stacked cold starts partially undercuts the cost-elasticity argument for going serverless in the first place; that is a real trade to make consciously, not a free win.
- Underestimating the application-side rework (retry logic, removing session-state dependencies) as "just an infrastructure migration" is how these migrations run over their planned timeline; budget for it as application work, not as a deployment configuration change.
Design an AWS RDS architecture for a read-heavy, customer-facing application that needs high availability across availability zones and horizontal read scaling. Describe your primary and read-replica placement, automated failover behavior, the connection-routing strategy for read/write separation, how you would handle replica lag, and how you would test failover.
Sample Answer
This architecture needs two structurally different mechanisms working together, not one: a Multi-AZ (availability zone) standby for automated failover, and a separate fleet of read replicas for horizontal read scaling. Conflating them is the most common design mistake here, since a Multi-AZ standby never serves read traffic at all; that is what read replicas are for.
flowchart TB
App[Application tier] --> Router[Read/write router, application- or proxy-side]
Router -->|writes| PrimaryEP[Primary instance endpoint, DNS CNAME]
Router -->|reads, chosen by app/proxy - RDS gives no built-in shared reader endpoint| Replica1[(Read replica, AZ-b)]
Router -->|reads, chosen by app/proxy - RDS gives no built-in shared reader endpoint| Replica2[(Read replica, AZ-c)]
PrimaryEP --> Primary[(Primary, AZ-a)]
Primary -.synchronous, HA only.-> Standby[(Multi-AZ standby, AZ-b)]
Primary -.asynchronous.-> Replica1
Primary -.asynchronous.-> Replica2
Primary and standby placement
The primary runs in one AZ; the Multi-AZ standby runs in a different AZ within the same region, kept current by synchronous replication (the primary does not acknowledge a write until the standby has it too). This standby exists purely for failover, it serves no read traffic under normal operation, which is the key fact that separates it from a read replica. The read replicas are placed across additional AZs (they can share an AZ with the standby; there is no requirement to keep them disjoint), sized in count to the actual read throughput need, addressed below.
Automated failover behavior
On primary failure or an AZ-level impairment, RDS promotes the standby and repoints the DB instance's single existing endpoint (its DNS CNAME, canonical name record) at the newly promoted instance rather than requiring any connection-string change. A classic RDS DB instance has exactly one endpoint total, not a separately named "writer endpoint" the way an Aurora cluster does, so failover here is a DNS re-point of that one address, not a switch between two differently-named endpoints. AWS states this happens "as quickly as 60 seconds" for a single-standby Multi-AZ deployment, with most failovers completing within one to two minutes. The part this leaves in the application's hands: a client with an existing connection to the now-dead primary, and a driver or pool that caches the resolved IP rather than re-resolving DNS promptly, can keep retrying a dead address well past the point RDS considers the failover complete. Short connection timeouts and prompt DNS re-resolution in the connection pool (the application's cache of reusable open database connections) are what actually determine how much of that 60-to-120-second window the application experiences as a real outage.
Connection-routing strategy for read/write separation
Two implementation options, and a fact that has to be stated up front: unlike Aurora, plain RDS does not give you a single, AWS-managed, load-balanced endpoint spanning multiple read replicas. Each RDS read replica is provisioned with, and reachable only through, its own individual endpoint, exactly like any other standalone RDS DB instance. Getting a single logical "read" address, if the application wants one, means building it, either in application code or via a proxy in front of the replica fleet; AWS does not hand it to you for free the way it does for Aurora's cluster reader endpoint.
- App-layer routing: hold the primary's own endpoint for writes, and the individual read replica endpoints for reads, and route each query explicitly in application code (round-robin, random choice, or a fixed per-service assignment across the known replica endpoints). Simplest to reason about, and its failure mode (a write accidentally sent to a read replica) is a loud, immediate error, since replicas reject writes, not a silent correctness bug.
- Proxy-layer routing: a pooler or router (for example a network load balancer or HAProxy in front of the replica fleet, or ProxySQL) that inspects statement type and routes automatically, which also gives the application a single logical address for reads instead of managing the replica endpoint list itself, at the cost of another moving part to operate.
For most teams, start with explicit app-layer routing; it is simpler, its failure mode is safe (a hard error, not silent data drift), and a routing proxy is worth adding later specifically once the number of call sites makes manual discipline unreliable, not as a default from day one.
Handling replica lag
Route only traffic that tolerates some staleness to the reader endpoint, browsing and search-style reads. Any read that must reflect the user's own just-completed write (an order confirmation immediately after checkout is the classic case) should either read from the writer directly for that specific call, or carry a short-lived "read your own write" hint that pins that one request to the writer rather than trusting the load-balanced reader endpoint. Monitor the replica lag metric per replica and treat a replica whose lag exceeds a defined threshold as degraded for routing purposes, since a healthy-but-lagged replica can otherwise keep receiving its normal share of read traffic through the load-balanced endpoint even while serving noticeably stale data.
Testing failover, not just designing for it
Design intent is not validation. Rehearse the actual failover, on a non-production copy at minimum, ideally occasionally against production during a planned low-traffic window once confidence is established:
aws rds reboot-db-instance --db-instance-identifier prod-webapp-db --force-failover
Measure the application's own observed error rate and recovery time during that test, not just the RDS-reported failover duration; those two numbers are not the same thing. A failover that completes on RDS's side in under a minute can still produce several minutes of application-visible errors if the connection pool does not detect the broken connection and re-resolve DNS promptly, which is exactly the gap the "automated failover behavior" section above flags as the application's responsibility, and the only way to know whether that gap is actually closed is to force a real failover and watch what the application does.
Worked example: sizing the read-replica count
peak_read_qps = 40_000
per_replica_sustained_qps = 8_000 # measured comfortable sustained capacity per replica
replicas_for_load = -(-peak_read_qps // per_replica_sustained_qps) # ceiling division
replicas_with_n_plus_1 = replicas_for_load + 1 # tolerate one replica down for maintenance or failure
print(f"Replicas needed to cover peak load: {replicas_for_load}")
print(f"Replicas with N+1 redundancy: {replicas_with_n_plus_1}")
print(f"Per-replica load with one of {replicas_with_n_plus_1} down: "
f"{peak_read_qps/(replicas_with_n_plus_1-1):,.0f} QPS")
Replicas needed to cover peak load: 5
Replicas with N+1 redundancy: 6
Per-replica load with one of 6 down: 8,000 QPS
Five replicas exactly cover the stated peak with zero slack, so losing even one to maintenance or a fault pushes the remaining four over their sustained capacity; provisioning a sixth (N+1) means the fleet still exactly meets sustained capacity, not exceeds it, with one replica out, which is the actual bar "can survive a single replica failure without degrading" sets.
Trade-offs and pitfalls
- Treating the Multi-AZ standby as if it also offloads read traffic is a common misunderstanding that leads teams to under-provision real read replicas; the standby's only job is failover.
- Aurora specifically allows a read replica to also serve as a Multi-AZ failover target if placed in a high-priority promotion tier (tiers run 0 to 15, and tier 0, the lowest number, is the highest priority for promotion, not tier 15), which blurs this line further in Aurora's favor (one fewer idle resource), and Aurora also provides a single load-balanced cluster reader endpoint spanning every Aurora Replica automatically. Neither behavior is something plain RDS read replicas provide: plain RDS replicas are each their own standalone endpoint, with no automatic promotion-to-failover-target and no built-in load balancing across them, which is exactly why a team that wants that behavior for free, rather than building it, often picks Aurora specifically for this reason.
- Skipping the forced-failover rehearsal is the single biggest gap between "designed for high availability" and "actually highly available": the DNS-flip mechanism and the AWS-stated failover time are necessary but not sufficient, since the application's own reconnect behavior is what determines real user-facing downtime.
- Load-balancing reads purely on the reader endpoint without a lag-aware exclusion means a badly lagged but technically healthy replica keeps taking its normal share of traffic, quietly serving stale reads to whichever users happen to be routed to it.
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.
Explain connection pooling and why it matters for managed databases, especially with serverless compute (AWS Lambda) and managed MySQL/Postgres. Name pooling solutions you'd consider, explain how you'd size the pool, and describe what you'd configure to avoid connection storms.
Sample Answer
Connection pooling reuses a small set of already-open database connections across many requests instead of opening a fresh connection (a TCP handshake plus authentication) for every request. It matters most acutely with serverless compute like AWS Lambda because each concurrent Lambda execution environment behaves like an independent short-lived process: if your code opens a database connection on invocation, a burst of concurrent invocations opens that many connections nearly simultaneously, and a managed MySQL or PostgreSQL instance has a hard max_connections ceiling tied to its instance size. A traffic spike that is entirely reasonable in query volume can still take the database down purely on connection count.
Why it matters beyond Lambda
Every open connection costs the database real memory and, for PostgreSQL specifically, a whole backend OS process, so connections are expensive per-unit even when idle. Opening and closing them constantly (rather than reusing a pool) adds latency and CPU overhead from repeated authentication and TLS negotiation on every request, on top of the risk of simply running out of connection slots.
Pooling solutions to consider
- RDS Proxy: AWS-managed, sits between the application and RDS (Amazon's managed relational database service for engines like MySQL and PostgreSQL) or Aurora (AWS's own MySQL- and PostgreSQL-compatible managed database with a different underlying storage engine). It pools and multiplexes connections, supports IAM authentication and credentials via AWS Secrets Manager, and automatically fails over to a standby while preserving application connections. It can only be attached to a writer instance, not a read replica, and it requires the proxy and the database to be in the same virtual private cloud (VPC).
- PgBouncer: self-run, the standard external pooler for PostgreSQL, used constantly in front of Lambda-to-Postgres workloads because of its transaction-mode pooling.
- ProxySQL: the MySQL equivalent, adding query routing and caching on top of pooling.
- Cloud SQL Auth Proxy / connectors: Google Cloud's equivalent pattern for Cloud SQL, handling authenticated, pooled connections from serverless callers.
Sizing the pool
Size the pool from actual concurrency, not guesswork, using Little's Law: the average number of concurrent database connections a workload needs equals its request rate multiplied by the average time each request holds a connection.
L=λ×Wrequests_per_sec = 2000 # peak invocation rate hitting the database
avg_query_duration_s = 0.015 # 15ms average time from "acquire connection" to "commit/release"
concurrent_db_connections_needed = requests_per_sec * avg_query_duration_s
db_max_connections = 1000 # example ceiling for a large Aurora instance class
usable_max_connections = db_max_connections - 50 # reserve headroom for admin/replication
headroom_multiplier = 3 # slack for variance and short bursts above the mean
recommended_pool_size = concurrent_db_connections_needed * headroom_multiplier
print(f"Concurrent DB connections needed on average: {concurrent_db_connections_needed:.1f}")
print(f"Recommended pool size with {headroom_multiplier}x headroom: {recommended_pool_size:.0f}")
print(f"That is {recommended_pool_size/usable_max_connections:.1%} of usable max_connections")
Concurrent DB connections needed on average: 30.0
Recommended pool size with 3x headroom: 90
That is 9.5% of usable max_connections
The point this makes concrete: even at 2,000 requests/sec, if each request only holds a connection for 15ms, the database only ever needs about 30 connections open at once on average, 90 with generous headroom. A pooler lets a huge number of Lambda-side clients share that small, stable set of database-side connections, which is the entire reason pooling and Lambda go together.
What to configure to avoid connection storms
- Use transaction-mode pooling, not session mode. In transaction mode, the database-side connection is returned to the pool the instant a transaction commits, not held for the life of the client's connection to the pooler. This is what lets 30 to 90 real database connections serve thousands of Lambda invocations: each invocation borrows a connection for milliseconds, not for its entire lifetime.
- Point Lambda only at the pooler's endpoint, never at the database engine directly. If any code path bypasses the pooler, it reintroduces the exact one-connection-per-invocation problem pooling exists to solve.
- Set the pooler's client-facing limit high but its database-facing limit bounded near the database's real capacity: thousands of client-side slots, tens to low hundreds of database-side ones.
- Set idle and statement timeouts so an abandoned or slow Lambda-side connection cannot hold a pooled database slot indefinitely.
- Avoid patterns that force "pinning." RDS Proxy (and poolers generally) fall back to a dedicated, unshared connection for a session that changes connection-level state, for example a session-level
SETstatement, an unclosed transaction, or, on RDS Proxy specifically, any statement larger than 16 KB. A pinned session stops multiplexing entirely for its lifetime, which quietly reintroduces the connection-storm risk the pooler was meant to prevent.
Trade-offs and pitfalls
- A pooler is another moving part with its own failure modes: if it goes down, so does every connection through it, so it needs to be highly available in its own right (RDS Proxy handles this for you; a self-run PgBouncer needs its own redundancy plan).
- Transaction-mode pooling breaks session-level features that assume a stable connection: prepared statements that persist across queries, session-level temp tables, and
LISTEN/NOTIFYin Postgres either don't work or behave differently. Audit the application for these before switching modes. - Pooling fixes connection exhaustion; it does not fix a database that is genuinely CPU- or IO-bound. If queries are slow, a pool just queues requests instead of rejecting them outright, which can turn a fast failure into a slow, harder-to-diagnose one if queue depth isn't monitored.
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.
Unlock Full Question Bank
Get access to all 6 Cloud and Managed Database Services interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.