Database Selection and Trade-offs Questions
Choosing the right database and data platform for a workload: relational versus NoSQL versus specialized stores, managed versus self-hosted, and matching technology to consistency, scale, cost, and query or access-pattern needs. Covers OLTP versus OLAP and transactional-versus-analytical workload splits, polyglot persistence across multiple data stores, structuring an ambiguous selection prompt, naming trade-offs, and defending a recommendation to stakeholders.
You must choose between a NoSQL wide-column store (Cassandra) and a cloud key-value store (DynamoDB) for a shopping-cart service that stores per-user cart state with heavy reads and occasional writes. Compare design considerations: data modeling, consistency options, TTL/expiry patterns, hotspots, repair/compaction, and operational burden. Provide decision criteria for mid-sized vs enterprise deployments.
Sample Answer
Direct answer
Add a third, often-overlooked option to this comparison: PostgreSQL with read replicas, which is the right call for a mid-sized team below a real, statable throughput threshold, since it avoids adding a second datastore entirely. Above that threshold, DynamoDB is the right default for most teams, mid-sized or enterprise, because it is fully managed (no repair or compaction to operate) and has native, built-in item expiry (time-to-live, TTL) that maps directly onto an abandoned-cart use case. Reserve Cassandra for a team that already operates a Cassandra fleet at real scale, or that specifically needs active-active writes across many regions with fine-grained, per-operation consistency tuning, or that needs to avoid single-cloud lock-in.
Structured elaboration
Decision matrix.
| Criterion | PostgreSQL + read replicas | DynamoDB | Cassandra |
|---|---|---|---|
| Best fit team / ops maturity | Small to mid-sized, already relational | Any size, comfortable with managed NoSQL data modeling | Team already running Cassandra at scale, or with dedicated distributed-systems operations capability |
| Existing infrastructure fit | Reuses an existing relational stack | Clean fit if already on AWS | Fits a multi-cloud or on-premises strategy |
| Write pattern needs | Single-region, single-writer is fine | Single- or multi-region (Global Tables) | Best for genuine multi-region active-active writes |
| Read-QPS threshold | Comfortable up to a moderate, well-indexed load (see worked example) | Scales past what a single relational primary and replica set can comfortably absorb | Scales similarly to DynamoDB, with more manual tuning |
| Cost model | Fixed instance and replica cost | Pay-per-request (on-demand) or provisioned capacity | Fixed cluster infrastructure cost, self-managed or via a vendor |
| Operational burden | Low, standard managed relational operations | Low, fully managed | High: repair and compaction must be actively operated |
| Native TTL / expiry | None; needs a scheduled job | Native, per-item, background-swept | Native, per-column or per-row |
| Vendor lock-in | Low (standard SQL, portable) | Higher (AWS-specific API) | Low (open-source, multi-cloud) |
Data modeling. All three model a cart the same conceptual way: one record per user_id (or cart_id), holding the current set of line items. DynamoDB embeds the line items as a list or map attribute on the item; Cassandra holds them as a collection type or as clustering-column rows under the same partition key; PostgreSQL stores them either as a JSONB column on the cart row or as a normalized cart_items child table, the more natural relational choice if line items ever need to be queried or joined independently (for example, for inventory reconciliation).
Consistency options. DynamoDB defaults to eventually consistent reads, with strongly consistent reads available per request, a good match for "read your own cart" if the read immediately follows the write on the same request path. Cassandra exposes consistency as a tunable per query (from ONE, a single replica, up to QUORUM, a majority of the replicas, or ALL, every replica), giving fine control at the cost of a decision the team has to make deliberately and correctly for every query pattern. PostgreSQL is trivially consistent on the single writer; its read replicas are asynchronous, so a cart view routed to a stale replica immediately after a write can show outdated data, a real and easy-to-miss bug unless the write path is designed to read its own write from the primary.
TTL and expiry, a genuine differentiator. DynamoDB and Cassandra both sweep and remove expired items automatically, in the background, at no query-time cost, a strong fit for "clear out abandoned carts after N days." PostgreSQL has no native equivalent; expiry has to be implemented as a scheduled job (a cron-triggered DELETE ... WHERE last_updated < now() - interval), which is a small but real, ongoing piece of operational surface that does not exist on the other two.
Hotspots. A common misconception is that a shopping-cart service hotspots on popular items during a flash sale. It does not, in any of the three designs above, because the partition or primary key is user_id, not item_id; cart writes are naturally spread across users, not concentrated on whatever product is trending. A real hotspot risk would only appear from a different, poor key choice, for example partitioning by store_id for a platform with one dominant retailer, which none of these three designs do here.
Repair and compaction, Cassandra's real operational cost. Cassandra requires operator-scheduled anti-entropy repair (reconciling replicas that have drifted, commonly run via nodetool repair on a regular cadence, before deleted data's tombstone markers expire past gc_grace_seconds and could resurface) and ongoing compaction-strategy tuning (choosing and tuning between strategies like size-tiered and leveled compaction for the actual write and read pattern). Both are genuine, continuous SRE work that DynamoDB and managed PostgreSQL (for example, Amazon RDS) simply do not require, since that maintenance is the vendor's responsibility in both of those options.
Worked example
Size DynamoDB's cost at a stated cart volume, and use it to reason about where the mid-sized-versus-enterprise threshold plausibly sits.
# DynamoDB on-demand monthly cost for a shopping-cart service.
carts = 2_000_000
reads_per_cart_per_day = 8
writes_per_cart_per_day = 3
monthly_reads = carts * reads_per_cart_per_day * 30
monthly_writes = carts * writes_per_cart_per_day * 30
price_per_million_read_eventual = 0.0625
price_per_million_write = 0.625
read_cost = monthly_reads / 1_000_000 * price_per_million_read_eventual
write_cost = monthly_writes / 1_000_000 * price_per_million_write
total = read_cost + write_cost
print(f"monthly reads = {monthly_reads:,}, monthly writes = {monthly_writes:,}")
print(f"DynamoDB on-demand monthly cost = ${total:,.2f} (${read_cost:,.2f} read + ${write_cost:,.2f} write)")
# monthly reads = 480,000,000, monthly writes = 180,000,000
# DynamoDB on-demand monthly cost = $142.50 ($30.00 read + $112.50 write)
At two million carts, DynamoDB's monthly cost is genuinely small, well within range of what a single well-provisioned PostgreSQL primary with a couple of read replicas would cost to run for the same load. This is the concrete basis for the "threshold" in the decision matrix: at this scale, the deciding factor is not cost, it is whether the team wants to operate a relational instance and its own expiry job (PostgreSQL) or hand that operational surface to a managed store (DynamoDB). The threshold shifts meaningfully once cart volume grows another order or two of magnitude, at which point a single relational primary's connection and write-throughput ceiling becomes the real constraint, not cost.
Trade-offs & pitfalls
- Assuming a NoSQL store is required "at scale" without checking whether PostgreSQL's actual ceiling has been reached. The worked example shows a mid-sized deployment can comfortably stay relational well past what feels like "real" scale.
- Believing shopping carts hotspot on popular items. They hotspot on users, not items, in a correctly keyed design; this misconception has led to unnecessary key-sharding work on systems that never needed it.
- Skipping Cassandra's repair schedule because the cluster "seems fine." Deferred repair risks deleted data resurfacing after
gc_grace_secondsexpires on a replica that missed a delete, a subtle and unpleasant correctness bug specific to Cassandra's eventually consistent deletion model. - Building a custom expiry job for PostgreSQL and letting it silently fail. Without alerting on the job's own health, an abandoned-cart cleanup job that stops running is invisible until storage or query performance visibly degrades.
- Choosing Cassandra for its consistency tunability without the operational maturity to actually operate repair and compaction correctly. The flexibility is only a genuine advantage in the hands of a team equipped to run it; otherwise it is pure added operational risk.
You're designing a user-profile service requiring flexible attributes, low-latency reads for 100M users, and occasional complex analytics queries. Compare using a relational DB versus a document NoSQL store for serving the profile API. Discuss data modeling, consistency, read and write patterns, caching needs, operational cost, and a migration path that supports both fast reads and analytics workloads.
Sample Answer
Direct answer
Serve the profile API from a document-oriented NoSQL store (DynamoDB or MongoDB, either fits this shape) rather than a relational database, because flexible per-user attributes and low-latency reads at 100 million users are exactly what a document store's native partitioning and schemaless record shape were built for. Never make that same store answer the "occasional complex analytics" requirement directly: feed a change-data-capture (CDC, a stream of every insert/update/delete as it happens) pipeline into a columnar analytical warehouse instead, so analytical scans never compete with the serving path for resources.
Structured elaboration
Why document over relational for the serving path. A relational schema for "flexible attributes" forces a choice between a wide, mostly-empty table (most columns null for most users, wasting storage and confusing every query planner statistic) or a key-value attribute table (user_id, attribute_name, attribute_value), which turns every profile read into a self-join and reintroduces exactly the problem a document store solves natively. A document model stores each user's profile, whatever shape it happens to have, as one self-describing record. Reading one profile is one partition read, not a join.
Data modeling. One document per user, keyed by user_id. Embed attributes that are almost always read together with the base profile (display name, avatar, preference flags); keep unbounded, ever-growing collections (activity history, full audit log) out of the profile document entirely, in a separate store keyed by user_id plus a time or sequence component, so the profile document itself stays small and cheap to read.
Consistency. The UX moment that matters is "I just edited my profile, does the app show my edit." That needs read-your-writes on the write path: use a strongly consistent read (DynamoDB's ConsistentRead=true, or MongoDB's read preference set to the primary) immediately after a write, and fall back to eventually consistent reads everywhere else, including any read replicas, since a moment of staleness on someone else's profile view is not user-visible or harmful.
Read and write pattern. The stated shape is read-heavy: 100 million users implies far more profile views than profile edits. That is the textbook case for a cache-aside layer.
Caching. Put Redis in front as a cache-aside layer: a read checks Redis first, falls through to the document store on a miss and populates the cache, and a write invalidates (or updates) the cached copy. A time-to-live (TTL, an automatic expiration the cache enforces) bounds how stale an uninvalidated entry can get as a safety net.
Operational cost. A managed document store's cost scales with actual request volume and storage, which is usually cheaper at this DAU-driven traffic shape than provisioning a relational read-replica fleet sized for the same peak, because the document store's partitioning is native and automatic rather than a fleet you provision and rebalance by hand.
Migration path that keeps both fast reads and analytics workable. Do not synchronously dual-write to both the serving store and the warehouse; that couples the two systems' availability and adds write latency to the serving path for no serving-path benefit. Instead, stream every change out of the serving store (DynamoDB Streams, or MongoDB Change Streams) asynchronously into the warehouse. The serving path stays fast and simple; the warehouse eventually reflects every change (typically within seconds), which is exactly what "occasional complex analytics" can tolerate.
Worked example
The instinct at "100 million users" is to assume enormous QPS (queries per second). Working the number through from a realistic daily-active fraction shows the opposite, and shows why the cache-aside layer does most of the real work.
# profile-read QPS and cost at 100M registered users.
users = 100_000_000
daily_active_fraction = 0.06 # 6% DAU/registered ratio, a reasonable consumer-app assumption
dau = users * daily_active_fraction
views_per_session = 4 # own profile + a few others viewed per session
daily_reads = dau * views_per_session
avg_qps = daily_reads / 86400
peak_concentration = 9 # traffic is not uniform across 24h; a peak-hour multiplier
peak_qps = avg_qps * peak_concentration
cache_hit_rate = 0.85
peak_origin_qps = peak_qps * (1 - cache_hit_rate)
print(f"DAU = {dau:,.0f}")
print(f"avg qps (all reads) = {avg_qps:,.0f}")
print(f"peak-hour qps (all reads) = {peak_qps:,.0f}")
print(f"peak qps actually reaching the document store after {cache_hit_rate:.0%} cache hit rate = {peak_origin_qps:,.0f}")
# DAU = 6,000,000
# avg qps (all reads) = 278
# peak-hour qps (all reads) = 2,500
# peak qps actually reaching the document store after 85% cache hit rate = 375
Two hundred and seventy-eight average, 2,500 peak, 375 peak at the origin store after caching: at 100 million registered users, that is a modest number for a document store built to handle tens of thousands of QPS per table. The real engineering problem this design has to solve is not raw throughput, it is p99 (99th-percentile) latency per request and cache-invalidation correctness on writes, and both of those are solved by the read-your-writes rule above, not by adding capacity.
Trade-offs & pitfalls
- Assuming "100 million users" implies enormous sustained load. It usually does not; work the DAU and session-shape assumptions through explicitly before sizing anything, and be ready to defend the assumptions, not the headline user count.
- Letting the analytics requirement pull the serving-path schema toward a relational, join-friendly shape "just in case." That is optimizing the 99% of traffic (serving) for the 1% of traffic (analytics), and it is exactly backwards; let the CDC pipeline and the warehouse absorb the analytical shape instead.
- Synchronous dual-writing to the warehouse. It seems simpler than a CDC pipeline but couples serving-path write latency and availability to the warehouse's, which defeats the entire point of separating the two workloads.
- Skipping the read-your-writes rule to save cost. It is tempting to serve every read eventually consistent for the lower price, but "I just saved my profile and it looks unsaved" is a support ticket generator; pay the strong-read cost only on the specific post-write read, not globally.
- Unbounded arrays embedded in the profile document (an ever-growing activity log, for example) quietly turn a cheap single-partition read into an expensive, growing one over a user's lifetime. Keep growth-shaped data in its own store from day one.
Tell me about a time you convinced stakeholders to change a database choice or architecture for a data product. Use the STAR method: situation, task, action, result. What metrics did you present to justify the change and how did you measure success afterwards?
Sample Answer
Direct answer
A strong answer here is a specific, bounded story: one database or architecture decision, one concrete problem it was causing, the evidence gathered to make the case, how the change was actually proposed and rolled out, and a real before/after number that a skeptical stakeholder could have checked themselves. The STAR structure (situation, task, action, result) is a good scaffold, but the part interviewers are actually listening for is whether the candidate can name the metric they presented and explain why it convinced a non-technical or differently-technical stakeholder, not just that they picked "the right" database.
How to structure the story
Situation. Set up the concrete pain, in terms a stakeholder felt, not an engineer's internal complaint. "Our database was slow" is weak; "checkout page load time was averaging 1.8 seconds at peak, and product analytics showed a measurable drop-off past 2 seconds" is a situation a product owner or a VP can immediately understand and care about.
Task. State what you were actually responsible for: diagnosing whether the database was the bottleneck, proposing an alternative, and building the case to get buy-in, given that changing the primary datastore is expensive and risky and stakeholders will reasonably default to "no."
Action. This is where the metrics belong, and where most weak answers go generic. A credible action sequence looks like: profiled the actual query patterns causing the slowdown, ran a proof of concept against the candidate replacement using production-shaped data volumes, measured the concrete improvement on the queries that mattered (not a synthetic benchmark), estimated the migration cost and risk (downtime window, rollback plan, engineering time), and presented that as a short, numbers-first case: current latency, projected latency, migration cost, and the risk being taken on. Naming the specific artifact (a one-page memo, a PoC dashboard, a bake-off table) makes the story concrete instead of generic.
Result. State the measured outcome after the change shipped, not just the projected one, and be honest if the outcome was mixed. "We projected a 40% latency reduction and measured a 35% reduction in production over the following month, with no increase in error rate" reads as more credible than a suspiciously perfect number, and shows the candidate actually checked their own prediction against reality instead of declaring victory at rollout.
What "measuring success afterward" should sound like
A convincing answer separates the metric used to justify the change from the metric used to confirm it worked, and explains how each was measured, for example: p95 checkout latency (95th-percentile latency: the value below which 95% of requests complete, a standard way to describe tail latency rather than a misleading average) pulled from existing application monitoring before and after the migration, error rate over the same window to confirm the new system didn't trade latency for reliability, and a business metric like checkout completion rate if the team could tie it back to the technical change. The strongest version of this answer explicitly says how long after the change the team waited before calling it a success (a week of stable metrics is a much stronger claim than "it looked good on day one").
Trade-offs and pitfalls
- Vague metrics are the single biggest tell of a fabricated or exaggerated story. "It got a lot faster" or an oddly precise, suspiciously round improvement number with no explanation of how it was measured both read as unconvincing; a real answer can say where the number came from (a specific dashboard, a specific query, a specific time window).
- Don't skip the pushback. Every real story like this involved someone reasonably asking "why do we need to change something that works," and a complete answer shows how that objection was actually addressed (usually with the same data used to make the original case), not glossed over.
- Be honest about a result that was mixed or smaller than hoped. An interviewer who has shipped a few of these themselves will trust a candidate more for saying "we projected 40% and got 35%, and here's why the gap" than for a story that sounds like everything went exactly as planned.
- If no real example exists, say so and reason through a realistic hypothetical instead of inventing false precision. A well-reasoned hypothetical with honestly-labeled assumptions is more credible, and less risky if a follow-up question probes deeper, than a fabricated story that cannot survive being pressed for specifics.
Design a hybrid OLTP/OLAP (HTAP) schema to support fast transactional operations (order placement) and low-latency analytics (live dashboards) on the same system. Discuss schema choices (normalized vs denormalized), indexing, how to protect transactional latency under analytic load, consistency models, and whether to use a purpose-built HTAP DB (TiDB, SingleStore) or maintain separate systems with CDC.
Sample Answer
Direct answer
Normalize the transactional core (orders, order items, payments) for correctness, so a checkout can never drift into a partially-updated state, and add a deliberately denormalized, separately-maintained analytic layer, rollup tables or a columnar replica, for the live dashboard, rather than denormalizing the transactional schema itself to serve both. Protect transactional latency by structurally separating where the analytic query executes: a replica, a columnar engine, or an isolated resource pool inside an HTAP database, never the same buffer pool and lock manager checkout writes to.
Structured elaboration
Normalized vs denormalized
Order placement needs a normalized schema (orders one-to-many order_items, a foreign key to payments) so a single update can't leave line items and totals inconsistent. The live dashboard wants pre-aggregated, denormalized rollups (orders per minute by region, say) because recomputing that aggregation from the normalized tables on every refresh means repeatedly scanning the same tables checkout is writing to.
Indexing
The transactional side wants few, narrow, high-selectivity indexes (indexes on columns with enough distinct values that a lookup quickly narrows to a small number of rows, instead of scanning a large chunk of the table) tuned for point lookups and inserts, because every extra index is write amplification (each index has to be updated too, so one logical write turns into several physical writes) on every insert and update. Analytic queries want either a columnar representation, compressed and scanned by column, or purpose-built aggregate tables. That is a fundamentally different access pattern than a small set of B-tree indexes (a sorted tree structure most relational databases use by default, good at point lookups and range scans over rows) can serve well at both ends.
Protecting transactional latency
Resource isolation is the core requirement: (a) a physically separate replica so analytic scans never share a buffer pool (the in-memory cache of recently used data pages) or lock manager (the component that tracks which rows are locked by in-progress transactions) with checkout writes, (b) if using a genuinely HTAP engine, isolate at the engine level (TiDB pairs a transactional row store, TiKV, with a separate columnar replica, TiFlash, and routes analytic queries to TiFlash's nodes so they don't consume TiKV's transactional resources; SingleStore's unified storage still benefits from routing heavy scans to dedicated compute), and (c) query timeouts and resource governors so a runaway dashboard query gets killed rather than starving checkout.
Consistency models
Dashboard reads are usually fine as read-committed (each query only sees data that has already been committed, though two steps of the same query can still see slightly different snapshots, unlike a stricter isolation level), or even bounded-staleness against a replica (orders 5 to 30 seconds old is normal for a live dashboard). Order placement needs full ACID within the checkout transaction: an order and its payment record commit together or not at all. Naming this distinction explicitly in the design, which paths get which guarantee, prevents someone downstream from assuming the whole system is uniformly strongly consistent.
HTAP database vs separate systems with CDC
Choose a purpose-built HTAP database when the dashboard needs to reflect committed writes within single-digit seconds and you want to operate one system instead of two. Choose CDC (change data capture: streaming each committed row change out of the database as an event) into a separate analytic system when the team already runs a mature analytics stack, when tens of seconds to a couple of minutes of dashboard staleness is acceptable, or when the transactional engine is fixed by other constraints (an existing investment, a compliance requirement) and swapping it isn't realistic.
Worked example
-- Transactional core (normalized)
CREATE TABLE orders (
order_id BIGSERIAL PRIMARY KEY,
customer_id BIGINT NOT NULL,
region TEXT NOT NULL,
status TEXT NOT NULL,
placed_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE order_items (
order_item_id BIGSERIAL PRIMARY KEY,
order_id BIGINT NOT NULL REFERENCES orders(order_id),
sku TEXT NOT NULL,
qty INT NOT NULL,
unit_price_cents BIGINT NOT NULL
);
CREATE INDEX idx_orders_customer ON orders(customer_id);
-- Analytic rollup, maintained out of band (CDC or a scheduled job), never read by checkout
CREATE TABLE orders_per_minute_by_region (
minute_bucket TIMESTAMPTZ NOT NULL,
region TEXT NOT NULL,
order_count BIGINT NOT NULL,
revenue_cents BIGINT NOT NULL,
PRIMARY KEY (minute_bucket, region)
);
The dashboard queries orders_per_minute_by_region, a handful of rows per screen refresh, instead of aggregating the full orders table, so its query cost stays roughly constant as orders grows, and checkout writes only ever touch orders and order_items, never contending with the dashboard's aggregation.
Trade-offs & pitfalls
Over-denormalizing the transactional side itself, embedding computed aggregates directly into orders, trades write-path correctness for read convenience and reintroduces the anomalies normalization exists to prevent. Under-isolating, letting the dashboard query the live orders table "just for now", is the single most common way this design degrades in production: a query that was fine at low volume becomes a lock-contention or cache-eviction problem once order volume climbs. On the HTAP side, only the specific tables the dashboard reads need dual row and columnar treatment; forcing every table in the schema onto the HTAP engine's more constrained feature set buys nothing.
You're evaluating AWS DynamoDB vs Amazon Aurora for a high-read e-commerce catalog with spiky traffic (100 RPS baseline, 50k RPS peak during sales). Compare cost, scaling behavior, latency, operational complexity, and how each handles hot keys and complex queries.
Sample Answer
Direct answer
Recommend DynamoDB in on-demand mode as the product-lookup store, with a cache (DynamoDB Accelerator, DAX, an in-memory cache layer built specifically for DynamoDB) in front of the hottest sale items, and a dedicated search engine (OpenSearch) handling faceted, filtered catalog browsing, rather than trying to make Aurora absorb the entire spike. The defining fact here is the spike ratio: 50,000 requests per second (RPS) at peak against a 100 RPS baseline is a 500-times multiplier, and DynamoDB on-demand is specifically built to scale to that kind of multiplier automatically, without pre-provisioning for a peak that occupies a small fraction of the traffic pattern.
Structured elaboration
Cost is close, so it is not the deciding factor here. The worked example below shows DynamoDB's and Aurora's illustrative monthly costs landing within about 13% of each other under stated assumptions. Anyone deciding this purely on a cost estimate is likely to be swayed by modeling noise, not a real difference; the real deciding factors are scaling behavior at the moment the spike begins, and how each handles the two named failure risks, hot keys and complex queries.
Scaling behavior, the real differentiator. DynamoDB on-demand mode scales to the request rate automatically and near-instantly for normal traffic growth; it has documented per-table scale-up behavior for very sudden, extreme jumps (typically able to handle roughly double the previous peak immediately, scaling further from there), which is a real characteristic to design around, not assume away, for a 500x jump. Aurora has two paths here, neither free: provisioning fixed instances sized for the 50,000 RPS peak means paying for that capacity essentially all the time it is not needed, which given the 100 RPS baseline is the overwhelming majority of the time; Aurora Serverless v2 scales continuously and avoids that waste, but scaling itself is not instantaneous, it takes real time to add Aurora Capacity Units (ACUs) as load ramps, which is a genuine availability risk in the first seconds to low minutes of a sudden flash-sale-style spike, precisely when the spike is at its least predictable.
Hot keys. "Spiky traffic during sales" usually means a small number of specific sale-item product IDs receive a hugely disproportionate share of the read traffic, not that load is evenly spread across the whole catalog. This is a genuine risk for DynamoDB specifically, since a single, extremely popular partition key can exceed what one partition can serve, even though the table overall has ample aggregate capacity; DynamoDB's adaptive capacity helps redistribute some of this automatically, but the reliable mitigation is a cache in front of the hottest handful of items (DAX, or a general-purpose cache like CloudFront or an application-level cache), which both engines effectively need anyway, since a single, extremely hot product page is a caching problem regardless of which database sits behind it.
Complex queries, the actual tie-breaker. Catalog browsing typically needs filtering and sorting across several attributes at once (price range, category, brand, availability), which is not something DynamoDB does well natively; it would require multiple global secondary indexes or an external search index to cover every meaningful filter combination. Aurora (or any relational store) answers this kind of ad hoc, multi-attribute filtered query natively through SQL and standard indexes. This is the genuine differentiator the question is testing by explicitly naming both hot keys and complex queries together: a design that only optimizes for the spike (DynamoDB alone) leaves faceted browsing weak, and a design that only optimizes for query flexibility (Aurora alone) takes on the biggest availability risk of the whole system, Aurora Serverless v2's scaling latency, right at the start of the highest-traffic, highest-revenue moment.
The recommended combination. DynamoDB on-demand for by-product-ID lookups (the pattern that actually drives the 50,000 RPS peak, since a shopper viewing a specific sale item is a single-key lookup), DAX caching the handful of genuinely hot items, and OpenSearch as the dedicated facet and filter layer for catalog browsing, which both an Aurora-based and a DynamoDB-based design would eventually need anyway once faceted search becomes a real product requirement, so it is not incremental complexity unique to this recommendation.
Worked example
# illustrative monthly cost, DynamoDB on-demand vs Aurora Serverless v2,
# for a catalog with a 100 RPS baseline and a 50,000 RPS sale-day peak.
baseline_rps, peak_rps = 100, 50_000
baseline_hours_per_day, peak_hours_per_day = 20, 4 # illustrative split: 4h/day of elevated sale traffic
daily_reads = baseline_rps * baseline_hours_per_day * 3600 + peak_rps * peak_hours_per_day * 3600
monthly_reads = daily_reads * 30
price_per_million_eventual = 0.0625
ddb_cost = monthly_reads / 1_000_000 * price_per_million_eventual
print(f"monthly reads = {monthly_reads:,}")
print(f"DynamoDB on-demand monthly read cost (eventual) = ${ddb_cost:,.2f}")
acu_price_hour = 0.12
baseline_acus, peak_acus = 4, 64 # illustrative: enough peak capacity to serve 50k RPS of point/range reads
monthly_acu_hours = (baseline_acus * baseline_hours_per_day + peak_acus * peak_hours_per_day) * 30
aurora_cost = monthly_acu_hours * acu_price_hour
print(f"Aurora Serverless v2 ACU-hours/month = {monthly_acu_hours:,.0f}")
print(f"Aurora Serverless v2 compute cost/month at ${acu_price_hour}/ACU-hr = ${aurora_cost:,.2f}")
# monthly reads = 21,816,000,000
# DynamoDB on-demand monthly read cost (eventual) = $1,363.50
# Aurora Serverless v2 ACU-hours/month = 10,080
# Aurora Serverless v2 compute cost/month at $0.12/ACU-hr = $1,209.60
Under these stated, illustrative assumptions, the two options land within about 13% of each other, close enough that neither is the deciding factor. What the calculation does surface: Aurora Serverless v2's cost model requires committing to a peak-ACU figure (64 ACUs, here) in advance to avoid under-provisioning; getting that number wrong either wastes money (too high) or reintroduces the scaling-latency risk during the spike (too low). DynamoDB's on-demand pricing needs no equivalent advance guess, which is a real operational simplicity advantage independent of the cost total itself.
Trade-offs & pitfalls
- Deciding this purely on a cost estimate. The worked example shows the two options landing close enough that cost alone should not drive the decision; scaling behavior and query-pattern fit matter more here.
- Assuming Aurora Serverless v2's continuous scaling is effectively instantaneous. It is not; the first seconds to low minutes of a sudden, extreme spike are the real risk window, and that risk is highest exactly when a flash sale begins.
- Assuming DynamoDB's overall table-level capacity protects against a single hot item. Table-wide headroom does not help a single overloaded partition key; the mitigation is caching the specific hot items, not just trusting aggregate scale.
- Trying to answer faceted catalog browsing with DynamoDB alone, via a growing pile of global secondary indexes for every filter combination. It technically works for a small, fixed set of filters and becomes unmanageable as filter combinations grow; a dedicated search index is the more honest long-term answer.
- Treating the search-layer addition as unique overhead of the DynamoDB-based design. A pure-Aurora design that wants the same faceted browsing quality would very likely need the same external search layer eventually; it is not a cost unique to the recommended path.
Unlock Full Question Bank
Get access to all Database Selection and Trade-offs interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.