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're designing the managed-database architecture for an ad-serving platform with 100M monthly active users. Characteristics: 95% reads, 5% writes; p95 read latency target < 50ms globally; peak reads 50k RPS; writes are small updates ~10k TPS during peak. Data shape: user preferences and campaign state, schema somewhat flexible. Recommend a managed database architecture (products and components) to meet the latency SLA and discuss caching, indexing, and operational concerns.
Sample Answer
This is a key-value access pattern (look up preferences and campaign state by user or campaign ID) at extreme read scale with a hard global latency target, so the recommendation is DynamoDB as the system of record, fronted by DynamoDB Accelerator (DAX, an in-memory read cache purpose-built for DynamoDB) in each region, replicated across regions with DynamoDB global tables, behind latency-based routing that sends each user to their nearest region.
flowchart LR
Client[Ad-serving client] --> Router[Latency-based routing]
Router --> AppUS[App tier, us-east-1]
Router --> AppEU[App tier, eu-west-1]
AppUS -->|read, cache-first| DAXUS[DAX cluster, us-east-1]
AppEU -->|read, cache-first| DAXEU[DAX cluster, eu-west-1]
DAXUS -->|cache miss| DDBUS[(DynamoDB table, us-east-1)]
DAXEU -->|cache miss| DDBEU[(DynamoDB table, eu-west-1)]
DDBUS <-.async global replication.-> DDBEU
Why this architecture fits the workload
- 95% reads, flexible schema: DynamoDB's item model (no fixed columns per row) fits user preference and campaign-state documents that vary in shape without requiring a schema migration every time a new attribute is added, and it is purpose-built for very high, uniformly-distributed read throughput.
- p95 read latency (the response time that 95% of requests come in at or under; the slowest 5% are allowed to exceed it) under 50ms globally: a single-region database cannot hit this for users far from it; global tables replicate the same table to multiple regions so every region has a local, complete copy, and DAX gives single-digit-millisecond to microsecond reads for cached keys on top of that.
- Writes are small, targeted updates: DynamoDB's per-item write model (not full-row rewrites, not multi-table joins) matches "update this user's preferences" or "update this campaign's remaining budget" well, and 5% writes at 10k TPS peak is comfortably within what a well-partitioned table handles.
Capacity math for the stated peak load
Assume a 1 KB average item size (a compact preference or campaign-state document) and a 90% DAX cache hit ratio for reads, both reasonable for a keyed lookup workload with a lot of repeat access to the same active users and campaigns. DynamoDB prices reads in read capacity units (RCU): a strongly consistent read of an item up to 4KB costs 1 RCU, but an eventually consistent read of the same item costs half that, 0.5 RCU, because DynamoDB can answer it from any replica without first confirming it has the very latest write. A cached preference or campaign-state read here does not need to reflect a write from the last few hundred milliseconds, so eventually consistent reads are the right, cheaper default; strongly consistent reads would double the RCU figures below:
peak_read_rps = 50_000
peak_write_tps = 10_000
dax_cache_hit_ratio = 0.90
RCU_PER_PARTITION = 3000 # AWS-documented per-partition ceiling (read units/sec)
WCU_PER_PARTITION = 1000 # AWS-documented per-partition ceiling (write units/sec)
rcu_per_read = 0.5 # eventually consistent read, item fits in one 4KB chunk
wcu_per_write = 1 # 1KB item fits in one 1KB chunk
backend_reads_per_sec = peak_read_rps * (1 - dax_cache_hit_ratio)
backend_rcu_per_sec = backend_reads_per_sec * rcu_per_read
worst_case_rcu_per_sec = peak_read_rps * rcu_per_read # DAX cold, e.g. right after a deploy
write_wcu_per_sec = peak_write_tps * wcu_per_write
print(f"Backend reads/sec with warm DAX: {backend_reads_per_sec:,.0f}")
print(f"Backend RCU/sec with warm DAX: {backend_rcu_per_sec:,.0f}")
print(f"RCU/sec if DAX is cold: {worst_case_rcu_per_sec:,.0f}")
print(f"WCU/sec (writes, uncacheable): {write_wcu_per_sec:,.0f}")
print(f"Min partitions from writes: {-(-write_wcu_per_sec // WCU_PER_PARTITION):.0f}")
print(f"Min partitions from cold-cache reads: {-(-worst_case_rcu_per_sec // RCU_PER_PARTITION):.0f}")
Backend reads/sec with warm DAX: 5,000
Backend RCU/sec with warm DAX: 2,500
RCU/sec if DAX is cold: 25,000
WCU/sec (writes, uncacheable): 10,000
Min partitions from writes: 10
Min partitions from cold-cache reads: 9
With a warm DAX cache, the DynamoDB table itself only has to absorb roughly 2,500 RCU/sec (well under one partition's ceiling), meaning the table's real sizing constraint here is the write path, which needs throughput spread across at least 10 partitions (10,000 WCU/sec divided by the documented 1,000 WCU-per-partition ceiling). On-demand capacity mode is the right choice at this scale rather than manually provisioned throughput, since the traffic pattern in an ad-serving platform (campaign launches, dayparting) is not perfectly steady, and on-demand removes the need to hand-tune provisioned throughput and auto scaling targets across two regions.
Caching, indexing, and operational concerns
- Partition key design: key user preference items by a well-distributed attribute like
user_id(100M distinct values spreads load evenly). Do not key campaign-state items bycampaign_idalone if a small number of high-spend campaigns dominate traffic; that concentrates writes on a few partitions and creates a hot partition even though the table's aggregate throughput looks fine. Use write sharding (a suffixed key likecampaign_id#shard_n) for any campaign whose write rate alone could approach the 1,000 WCU-per-partition ceiling. - DAX: run a DAX cluster with at least 3 nodes across availability zones (AZs) per region for high availability, and set a write-through or short time-to-live (TTL, how long a cached value is trusted before being refetched) policy on campaign-state items specifically, since a stale campaign budget or targeting rule served from cache for too long has real business cost (overspend, mistargeting), unlike a slightly stale user preference.
- Global tables and consistency: replication between regions is asynchronous and uses last-writer-wins conflict resolution, so a user who is rerouted between regions (failover, or a mobile client crossing a region boundary) can briefly see a slightly older version of their own last write. This is acceptable for preferences and most campaign state, but if a specific field (for example remaining campaign budget) must never double-spend across regions, that field needs a different pattern, for example routing all writes for a given campaign to a single "home" region rather than treating every region as equally writable.
- Monitoring: alarm on
ThrottledRequestsandConsumedWriteCapacityUnitsper table (and per partition-level hot-key indicators), DAX cache hit rate (a real hit ratio far below the assumed 90% means the 2,500 RCU/sec sizing estimate above is wrong and the table needs to absorb more direct traffic), and cross-region replication latency for global tables. - Indexing beyond the primary key: add global secondary indexes (GSIs) only for query patterns that genuinely need them (for example looking up all campaigns for an advertiser), since every GSI is itself a separately-partitioned, separately-throughput-provisioned structure with its own hot-key risk, not a free index the way a relational database's secondary index is.
Describe encryption in transit and at rest for managed database services. For AWS RDS/Aurora: list the steps you'd take to verify TLS is enforced on connections, confirm encryption at rest is enabled using KMS, and validate that snapshots and read replicas remain encrypted. Mention potential performance impacts and key rotation considerations.
Sample Answer
Encryption at rest and encryption in transit are two separate controls on RDS and Aurora, and verifying "the database is encrypted" means checking both independently, plus confirming the encryption actually propagates to every derived artifact (snapshots, same-region replicas), since none of that is a single toggle.
Verifying TLS is enforced on connections
- Check the engine parameter that forces secure connections:
rds.force_sslfor PostgreSQL,require_secure_transportfor MySQL, in the instance's parameter group, and confirm it is set to require (not merely allow) TLS. - Connect and confirm the connection actually negotiated TLS: on PostgreSQL,
SHOW ssl;should returnon; on MySQL,SHOW STATUS LIKE 'Ssl_cipher';should return a non-empty cipher name (an empty result means the connection is not encrypted). - Confirm the application's own connection string requests TLS (for example
sslmode=requireon PostgreSQL). Enforcing the server-side parameter without updating every client is a coordinated two-sided change: once enforcement is on, a client that does not request TLS is rejected outright at connection time, not degraded gracefully, so this needs to be tested in staging before it is flipped on in production. - Confirm the client's trust store has the current
rds-cacertificate bundle. AWS periodically rotates these certificates with advance notice and a transition period; a client trusting only the old certificate will start failing to connect at the rotation deadline, which shows up as a hard cutover, not a gradual warning.
Verifying encryption at rest and confirming it propagates
- Confirm the instance itself is encrypted:
aws rds describe-db-instances --db-instance-identifier mydb --query "*[].{StorageEncrypted:StorageEncrypted}" --output text, or the Encryption field under Configuration in the console. Also note which AWS Key Management Service (KMS) key ID is attached, an AWS-managed key or a customer-managed key. - Confirm snapshots are encrypted with the same key as the source. This is enforced by RDS, not something you can misconfigure: an unencrypted instance cannot produce an encrypted snapshot directly, only via copying an existing snapshot with encryption enabled, and any snapshot of an already-encrypted instance must use the same KMS key as that instance.
- Confirm same-region read replicas use the identical KMS key as the primary, again structurally enforced (you cannot pair an encrypted primary with an unencrypted replica, or the reverse). A cross-region replica uses a key in its own destination region instead, since KMS keys are region-scoped, so verifying a cross-region replica means checking the destination region's key, not re-checking the source's.
Illustrative shape of a verification run (not a captured live run)
$ psql "host=mydb.xxxx.rds.amazonaws.com sslmode=require" -c "SHOW ssl;"
ssl
-----
on
$ aws rds describe-db-instances --db-instance-identifier mydb \
--query "*[].{StorageEncrypted:StorageEncrypted,KmsKeyId:KmsKeyId}"
[{"StorageEncrypted": true, "KmsKeyId": "arn:aws:kms:us-east-1:111122223333:key/abcd-..."}]
This is the shape of what a passing check looks like, not a run against a real instance; the actual output depends on the specific instance being checked.
Performance impact
AWS states that encryption at rest is handled transparently, using AES-256, with minimal performance impact, since the underlying hardware accelerates the cryptographic operations. In practice, at-rest encryption overhead is not a meaningful factor in sizing decisions for the vast majority of workloads. TLS in transit adds a small, mostly one-time cost at connection setup (the handshake), not a meaningful per-query cost once a connection is established; this is one more reason connection pooling matters for high-request-rate applications, since pooling means paying that handshake cost once per pooled connection rather than once per request.
Key rotation considerations
AWS-managed KMS keys rotate automatically every year with no ability to disable it. Customer-managed keys support optional automatic rotation, off by default, with a 365-day default rotation period that can be customized. The important nuance: rotation changes only the current key material used for new encryption operations going forward. It does not re-encrypt data that is already on disk, and decrypting existing data continues to transparently use whichever key material version originally encrypted it. This means rotation is not a way to "refresh" the encryption on data already written, and it does not reduce exposure from an already-compromised key, since the compromised key material remains valid for decrypting everything it originally encrypted. Genuinely rotating away from a suspected-compromised key means creating a new KMS key and re-encrypting the actual data end to end, which for RDS means the same snapshot-copy-with-a-new-key-then-restore cycle used to add encryption to a previously unencrypted instance, not simply toggling key rotation on.
Trade-offs and pitfalls
- Enforcing TLS on the server before every client is updated causes a hard outage at the moment of enforcement, not a gradual one; roll it out in a lower environment first and confirm every consumer's connection string before flipping the production parameter.
- At-rest encryption protects data on disk; it does not protect credentials or query data while they are moving between the application and the database. Treat the two as independent requirements, both need to be explicitly verified, neither implies the other.
- Assuming key rotation re-encrypts existing data is a common and consequential misunderstanding: if a key rotation cadence is being used to satisfy a compliance requirement, confirm with whoever owns that requirement whether rotating the key material is actually sufficient, or whether the requirement really means re-encrypting the data itself.
- Forgetting to check that a cross-region replica or a copied snapshot is encrypted with the correct destination-region key is an easy gap, since the source region's key ID is not valid in another region and the failure shows up as a create-time error, not a silent gap, but only if someone is actually watching for it.
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.
Compare provisioned capacity (reserved throughput) with serverless/autoscaling models for DynamoDB and Aurora Serverless v2. Discuss cost predictability, latency characteristics, cold-start behavior, throttling, operational overhead, and what kind of workload pattern each model suits best.
Sample Answer
Provisioned capacity means you reserve a fixed amount of throughput (how many read or write operations, or how much compute, the system can handle per second) up front and pay for it whether you use it or not; serverless/autoscaling means the service adjusts capacity to match load and you pay closer to actual consumption. The two managed products that expose this choice most directly are DynamoDB (provisioned throughput vs. on-demand) and Aurora (a fixed instance class vs. Serverless v2), and the right choice depends almost entirely on how predictable and how bursty the workload is.
DynamoDB: provisioned throughput vs. on-demand
| Provisioned | On-demand | |
|---|---|---|
| Cost predictability | High: you set read capacity units (RCU) and write capacity units (WCU) and pay a flat rate for them | Lower: billed per request, cost tracks traffic directly, which is predictable only if traffic is predictable |
| Latency | Same single-digit-millisecond latency as on-demand; capacity mode does not change per-request latency | Same latency profile as provisioned |
| Throttling behavior | Requests beyond provisioned capacity are throttled (ProvisionedThroughputExceededException) unless application auto scaling is configured, and auto scaling reacts to a CloudWatch alarm on a delay, not instantly | Scales automatically to serve the traffic, but a sudden spike well beyond the table's recent peak can still see brief throttling until DynamoDB provisions more partitions behind the scenes |
| Operational overhead | You own setting and tuning target utilization for auto scaling, and re-tuning it as traffic patterns shift | Effectively none: no capacity numbers to manage |
| Best workload pattern | Steady, forecastable traffic where the flat provisioned rate beats per-request pricing | Spiky, new, or hard-to-forecast traffic, or a small table where operational simplicity matters more than shaving cost |
Aurora: provisioned instance vs. Aurora Serverless v2
| Provisioned | Serverless v2 | |
|---|---|---|
| Cost predictability | High: fixed instance-class price regardless of load | Variable: billed in Aurora capacity unit (ACU) hours, each ACU is roughly 2 gibibytes (GiB) of memory plus corresponding CPU and networking, measured every second |
| Latency characteristics | Constant, matches the chosen instance class | Same engine, same query latency at a given capacity; latency only changes if the workload outgrows the current ACU level faster than it can scale up |
| Cold-start behavior | None: capacity is always provisioned | None for the normal 0.5 to 256 ACU scaling range, since scaling happens in place (typically the same host) without dropping connections; a cold-start-like delay only appears if you opt into "scale to zero" (available on newer engine versions with a minimum of 0 ACUs) and the cluster has to resume from a fully paused state |
| Throttling | N/A: fixed capacity either handles the load or the instance is CPU/memory saturated | Scales up automatically in increments as small as 0.5 ACU as load increases; a very sudden spike can still see brief elevated latency while capacity catches up, but there is no hard throttling wall the way DynamoDB provisioned mode has |
| Operational overhead | Manual: resizing the instance class is a deliberate, brief-outage operation you schedule | Low: you set a minimum and maximum ACU range once and the service scales within it continuously |
| Best workload pattern | Steady-state OLTP (online transaction processing) load where you can predict peak capacity and want the most predictable bill | Spiky or unpredictable workloads (promotions, seasonal traffic, dev/test environments that sit idle most of the day) where paying for idle provisioned capacity would be wasteful |
Worked example: turning a workload into numbers
DynamoDB. Say a product-catalog table needs to sustain a peak of 800 strongly consistent reads/sec (items averaging 3 KB) and 150 writes/sec (items averaging 1.5 KB). DynamoDB charges 1 RCU (read capacity unit) per strongly consistent read of an item up to 4 KB, and 1 WCU (write capacity unit) per write of an item up to 1 KB, rounding each item up to the next chunk boundary:
import math
peak_reads_per_sec = 800
peak_writes_per_sec = 150
read_item_kb = 3
write_item_kb = 1.5
rcu_per_read = math.ceil(read_item_kb / 4) # 3KB fits in one 4KB chunk -> 1 RCU
wcu_per_write = math.ceil(write_item_kb / 1) # 1.5KB needs two 1KB chunks -> 2 WCU
read_rcu_per_sec = peak_reads_per_sec * rcu_per_read
write_wcu_per_sec = peak_writes_per_sec * wcu_per_write
headroom = 1.2 # 20% buffer above measured peak
provisioned_rcu = math.ceil(read_rcu_per_sec * headroom)
provisioned_wcu = math.ceil(write_wcu_per_sec * headroom)
print(f"Peak RCU/sec needed: {read_rcu_per_sec}")
print(f"Peak WCU/sec needed: {write_wcu_per_sec}")
print(f"Provisioned RCU to reserve (20% headroom): {provisioned_rcu}")
print(f"Provisioned WCU to reserve (20% headroom): {provisioned_wcu}")
Peak RCU/sec needed: 800
Peak WCU/sec needed: 300
Provisioned RCU to reserve (20% headroom): 960
Provisioned WCU to reserve (20% headroom): 360
Under provisioned capacity, you reserve and pay for 960 RCU and 360 WCU every hour of the day, including overnight when actual traffic might fall to 50 reads/sec and 10 writes/sec (50 RCU and 20 WCU, under 6% of what is provisioned). Under on-demand, you are billed only for the RCU and WCU each request actually consumes, so that overnight trough costs proportionally less, at a higher per-unit rate for whichever units you do consume. This is the concrete version of the "idle capacity" trade-off in the table above: provisioned wins when the 800/150 peak is close to the round-the-clock average, on-demand wins when it is not.
Aurora Serverless v2. Say a workload idles near the 1 ACU minimum for 20 hours a day and spikes to 8 ACU for a 4-hour business-hours peak. An Aurora capacity unit (ACU) is billed per second, in ACU-hours:
idle_hours, idle_acu = 20, 1
peak_hours, peak_acu = 4, 8
daily_acu_hours = idle_hours * idle_acu + peak_hours * peak_acu
rate_per_acu_hour = 0.12 # AWS's published Aurora Serverless v2 rate, us-east-1 at time of writing; check current pricing for your region
daily_cost = daily_acu_hours * rate_per_acu_hour
monthly_cost = daily_cost * 30
provisioned_daily_acu_hours = 24 * peak_acu # a fixed instance sized for the peak, running all day
provisioned_monthly_cost = provisioned_daily_acu_hours * rate_per_acu_hour * 30
print(f"Serverless v2 ACU-hours/day: {daily_acu_hours}")
print(f"Serverless v2 monthly compute cost: ${monthly_cost:,.2f}")
print(f"Fixed-at-peak monthly compute cost: ${provisioned_monthly_cost:,.2f}")
Serverless v2 ACU-hours/day: 52
Serverless v2 monthly compute cost: $187.20
Fixed-at-peak monthly compute cost: $691.20
For this bursty, mostly-idle shape, Serverless v2 costs about 73% less than a provisioned instance sized to never fall short at the 4-hour daily peak, because the provisioned instance bills for 8-ACU-equivalent capacity for all 24 hours whether the workload needs it or not. A workload that instead sat near 8 ACU around the clock would flip this: Serverless v2 would bill close to the same 192 ACU-hours/day as the provisioned option, at a higher per-ACU-hour rate, making the fixed instance the cheaper choice.
Trade-offs and pitfalls
- Provisioned capacity is not "safer," it is differently risky: undersized provisioned throughput throttles real user traffic with a hard error, while serverless/on-demand's failure mode is a cost spike or brief latency bump, not a hard rejection. Which failure mode is worse depends on whether the business cares more about a predictable bill or never dropping a request.
- On-demand and Serverless v2 both have a per-unit price premium over well-utilized provisioned capacity. The trade only pays for itself when the workload's peak-to-average ratio is high enough that you would otherwise be paying for a lot of idle provisioned headroom; for a genuinely flat, 24/7 workload, provisioned is usually cheaper.
- Aurora Serverless v2's scale-to-zero option is attractive for dev/test but is a different feature from its normal 0.5 to 256 ACU scaling: only enable it where an occasional resume delay is acceptable, not on anything customer-facing.
- Mixing modes inside one system is a legitimate design, not a compromise: for example, a steady OLTP writer on a provisioned Aurora instance with Serverless v2 read replicas that scale independently to absorb bursty reporting traffic, or a DynamoDB table on provisioned capacity for its steady core traffic with on-demand reserved for a table that only exists to catch spiky, unpredictable event ingestion.
Your team needs to forecast storage, IOPS, and throughput requirements for an RDS/Aurora instance and a DynamoDB table over the next 12 months of projected traffic growth. Walk through how you'd build this capacity planning model: what data you'd need to collect, how you'd build in margin for spikes and bursts, and how you'd turn the forecast into automated scaling and cost alerts.
Sample Answer
A 12-month capacity forecast has four parts: a measured baseline (not a guess), a growth rate applied to that baseline, a burst margin derived from real observed peak-to-average behavior rather than an arbitrary buffer percentage, and thresholds along that projected curve wired into actual scaling actions and cost alerts, not left as a one-time spreadsheet nobody revisits.
What data to collect
- Current baseline, from monitoring, not estimation: for the RDS (Amazon's managed relational database service) or Aurora (AWS's own MySQL- and PostgreSQL-compatible managed database) instance,
WriteIOPSandReadIOPS(IOPS: input/output operations per second, a count of individual read or write operations the storage can perform each second, distinct from throughput's raw bytes-per-second measure),CPUUtilization,DatabaseConnections, and theFreeStorageSpacetrend over time; for the DynamoDB table,ConsumedReadCapacityUnits(RCU, read capacity units) andConsumedWriteCapacityUnits(WCU, write capacity units), andThrottledRequests. - A real growth rate: either the business's stated growth target (for example "20% month-over-month user growth" from the product side) or a rate derived from a trailing 90-day trend in the metrics above, whichever is more trustworthy for this system.
- A real peak-to-average ratio, measured over at least one full traffic cycle (a week captures daily and weekly cyclicality; if the business has a known monthly or seasonal peak, for example end-of-month billing runs or a holiday shopping spike, the measurement window has to cover it, or the ratio will understate the real burst).
- Storage growth rate separately from throughput growth: storage is cumulative and tends to grow closer to linearly (data doesn't shrink), while throughput growth tracks concurrent traffic and tends to compound with user growth. Modeling both with the same curve shape produces a wrong forecast for at least one of them.
- Known step-changes: a planned feature launch, a migration bringing another system's traffic onto this database, or a planned deprecation, none of which a smooth growth-rate model captures, and all of which should be layered on top of the smooth projection as a manual adjustment.
Building in margin for spikes and bursts
Apply the measured peak-to-average ratio to the projected average, then provision to a target utilization below that peak figure (for example 70%), so there is headroom for the unpredictable stacked on top of the predictable growth trend. Treat storage differently: it should be governed by autoscaling with a hard ceiling you set deliberately, since running out of storage causes writes to fail outright, not merely slow down, so "provision to 70% of projected peak" is the wrong model for storage; "never let it get within a safety margin of full" is the right one.
Turning the forecast into automated scaling and cost alerts
- Set an alert threshold below the "provision to" figure (for example 80% of the provisioned target), giving lead time to act before actually hitting a ceiling.
- Wire the storage growth projection into RDS storage autoscaling with an explicit
max_allocated_storageceiling, so autoscaling absorbs organic growth automatically but cannot silently run away and blow the budget if something goes wrong (a bug causing runaway writes, for example). - For DynamoDB, either use on-demand capacity mode and alert on sustained
ThrottledRequestsas the safety net, or use provisioned mode with application auto scaling policies keyed to the same target utilization used in the forecast, so the automated scaler and the capacity plan agree on what "comfortable" means. - Set an independent monthly cost-anomaly alert (for example AWS Budgets or Cost Anomaly Detection) as a second, separate check from the capacity forecast itself: the forecast is a model built on assumptions, the actual bill is ground truth, and a growing gap between the two means the model's growth rate or peak ratio needs revisiting, not that the schedule of numbers needs a one-off patch.
Worked example: a reproducible 12-month projection
months = 12
baseline_write_iops = 4_000
baseline_storage_gb = 500
baseline_dynamodb_wcu = 1_200
monthly_growth_rate = 0.06 # 6%/month, from the product's stated growth target
peak_to_average_ratio = 2.5 # measured from the last 90 days of CloudWatch data
target_utilization = 0.70 # provision so sustained load stays at or below 70%
alert_threshold = 0.80 # alert when consumption crosses 80% of provisioned capacity
monthly_storage_growth_gb = 40 # storage grows closer to linearly, not compounding
WCU_PER_PARTITION = 1000 # documented per-partition ceiling
def project(baseline, month, growth_rate):
return baseline * ((1 + growth_rate) ** month)
print("-- IOPS: compounding growth, peak margin, provisioning + alert targets --")
for m in [0, 3, 6, 9, 12]:
avg_iops = project(baseline_write_iops, m, monthly_growth_rate)
peak_iops = avg_iops * peak_to_average_ratio
provision_to = peak_iops / target_utilization
print(f"month {m:2}: avg {avg_iops:7,.0f} IOPS, peak {peak_iops:7,.0f}, "
f"provision to {provision_to:8,.0f}, alert at {provision_to*alert_threshold:7,.0f}")
print("\n-- Storage: linear growth, flat 25% autoscale ceiling margin --")
for m in [0, 3, 6, 9, 12]:
storage = baseline_storage_gb + monthly_storage_growth_gb * m
ceiling = storage * 1.25
print(f"month {m:2}: {storage:6,.0f} GB actual -> {ceiling:6,.0f} GB autoscale ceiling")
print("\n-- DynamoDB WCU: compounding growth, converted to partitions needed --")
for m in [0, 3, 6, 9, 12]:
avg_wcu = project(baseline_dynamodb_wcu, m, monthly_growth_rate)
peak_wcu = avg_wcu * peak_to_average_ratio
partitions = -(-peak_wcu // WCU_PER_PARTITION) # ceiling division
print(f"month {m:2}: {avg_wcu:6,.0f} avg -> {peak_wcu:6,.0f} peak -> {partitions:.0f} partitions needed")
-- IOPS: compounding growth, peak margin, provisioning + alert targets --
month 0: avg 4,000 IOPS, peak 10,000, provision to 14,286, alert at 11,429
month 3: avg 4,764 IOPS, peak 11,910, provision to 17,015, alert at 13,612
month 6: avg 5,674 IOPS, peak 14,185, provision to 20,265, alert at 16,212
month 9: avg 6,758 IOPS, peak 16,895, provision to 24,135, alert at 19,308
month 12: avg 8,049 IOPS, peak 20,122, provision to 28,746, alert at 22,997
-- Storage: linear growth, flat 25% autoscale ceiling margin --
month 0: 500 GB actual -> 625 GB autoscale ceiling
month 3: 620 GB actual -> 775 GB autoscale ceiling
month 6: 740 GB actual -> 925 GB autoscale ceiling
month 9: 860 GB actual -> 1,075 GB autoscale ceiling
month 12: 980 GB actual -> 1,225 GB autoscale ceiling
-- DynamoDB WCU: compounding growth, converted to partitions needed --
month 0: 1,200 avg -> 3,000 peak -> 3 partitions needed
month 3: 1,429 avg -> 3,573 peak -> 4 partitions needed
month 6: 1,702 avg -> 4,256 peak -> 5 partitions needed
month 9: 2,027 avg -> 5,068 peak -> 6 partitions needed
month 12: 2,415 avg -> 6,037 peak -> 7 partitions needed
This is the actual deliverable: not one number, but three small tables of thresholds at defined checkpoints, each mapping to a concrete provisioning target and a concrete alert value, so "are we still on track" is a five-minute check against real metrics rather than a re-derivation from scratch.
Trade-offs and pitfalls
- A compounding growth model overshoots badly if real growth is seasonal or step-shaped rather than smoothly exponential; validate the growth-rate assumption against at least two historical data points before trusting a 12-month compounding projection, and re-check it against actuals quarterly rather than treating the forecast as fixed.
- A peak-to-average ratio measured over too short a window will understate real bursts if the true cycle is monthly, quarterly, or seasonal; a week of clean data during a quiet month is not a substitute for capturing the actual peak event.
- Over-provisioning "to be safe" defeats the purpose of building a data-driven model in the first place, and it is a genuinely expensive habit at scale: the entire value of this exercise is replacing a guessed buffer with a measured one.
- The forecast needs a revisit cadence built in from the start (for example, re-run monthly with actuals), since a growth-rate assumption that was right in month 0 is rarely still right in month 12 without at least one course correction along the way.
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.