DynamoDB

Best Practices Interview Questions

Best Practices interview questions for DynamoDB — fundamentals through advanced scenarios.

  • 20Questions with answers
  • 3Difficulty levels

Questions (20)

Browse beginner, intermediate, and advanced questions with answers — hide them when you want to self-test.

Question 1
Interview Beginner
Question

Why should DynamoDB table design start from access patterns instead of a relational schema?

Answer:

DynamoDB does not join across tables efficiently, so you model the queries you must serve first. List read/write paths, then choose partition and sort keys that answer those paths with Query rather than Scan. A 3NF schema imported from SQL usually produces hot partitions, extra round-trips, or expensive scans.

Question 2
Interview Beginner
Question

How do you choose a partition key that avoids hot partitions?

Answer:

Pick an attribute with high cardinality that spreads traffic evenly, such as userId or orderId, not a low-cardinality status flag. Watch CloudWatch for throttling concentrated on one partition key value. If a popular entity still dominates traffic, add a sharding suffix or cache that item.

Question 3
Interview Beginner
Question

When should you use a composite primary key with a sort key?

Answer:

Use a sort key when many items share a partition and you need range queries, newest-first lists, or 1:N collections such as ORDERS#<id> under a customer partition. Begins_with and between on the sort key keep related items colocated without a Scan. Skip a sort key only for true single-item lookups.

Question 4
Interview Beginner
Question

Why is Query preferred over Scan in production DynamoDB workloads?

Answer:

Query reads only items that match a partition key (and optional sort-key condition), so cost and latency stay proportional to the result set. Scan reads the whole table or index and burns capacity even when you filter afterward. Use Scan for rare admin jobs, not user-facing request paths.

Question 5
Interview Beginner
Question

How should you handle items that would exceed DynamoDB’s 400 KB size limit?

Answer:

Keep items small: store large blobs in S3 and persist the object key in DynamoDB, or split wide documents into multiple items under the same partition. Oversized items increase read cost, slow replication, and fail writes. Compress only when you still stay well under the limit and can decode consistently.

Question 6
Interview Beginner
Question

What is a sparse GSI and why is it a DynamoDB best practice?

Answer:

A sparse GSI only projects items that actually have the index’s key attributes, so most rows never appear. Use it for rare states such as “pending review” without duplicating the entire table. That keeps the index small, cheaper to write, and fast to Query.

Question 7
Interview Beginner
Question

When would you pick on-demand capacity instead of provisioned mode?

Answer:

On-demand fits spiky or unknown traffic because you pay per request and skip capacity planning. Provisioned (with auto scaling) is usually cheaper for steady, predictable load. Switch only after measuring request rates; mixing modes without a traffic profile often wastes money or still throttles.

Question 8
Interview Intermediate
Question

How do you shard a hot partition key that you cannot replace?

Answer:

Append a shard suffix (userId#0 … userId#N) on writes and fan out reads across shards, or cache the hot item. Adaptive capacity helps short bursts but will not fix a permanently skewed key. Document shard count and aggregation so new features do not write to a single physical partition again.

Question 9
Interview Intermediate
Question

When should you use DynamoDB transactions instead of a single Put or Update?

Answer:

Use TransactWriteItems when multiple items must commit or fail together, such as inventory decrement plus order create. Transactions cost extra write units and cap at 100 items, so do not wrap every request. For idempotent retries of one item, a condition expression is cheaper and sufficient.

Question 10
Interview Intermediate
Question

How does Time to Live (TTL) support DynamoDB operational best practices?

Answer:

TTL deletes expired items in the background so session, cache, and event tables do not grow forever. Deletion is eventually consistent and not real-time, so do not treat TTL as a security purge SLA. Combine TTL with Streams if downstream systems must react to expiry.

Question 11
Interview Intermediate
Question

What client retry and idempotency practices should you use when DynamoDB throttles?

Answer:

Retry with exponential backoff and jitter on ProvisionedThroughputExceededException or HTTP 429. Make writes idempotent with client tokens or condition checks so retries do not double-apply money or inventory changes. Unbounded immediate retries amplify hot partitions and make throttling worse.

Question 12
Interview Intermediate
Question

How do Condition Expressions implement optimistic locking in DynamoDB?

Answer:

Store a version attribute and require it to match on UpdateItem so concurrent writers cannot silently overwrite each other. On condition failure, re-read, merge, and retry. This is the standard DynamoDB alternative to relational row locks and pairs well with retries that are already required for throttling.

Question 13
Interview Intermediate
Question

When is DAX a good fit, and what consistency trade-off does it introduce?

Answer:

DAX helps read-heavy, key-value access patterns that tolerate microsecond cache hits and can accept eventually consistent cached data. It does not speed Queries/Scans the same way and is a poor fix for a bad data model. Strongly consistent reads bypass DAX, so design which paths may be stale.

Question 14
Interview Intermediate
Question

How do you decide between single-table design and multiple DynamoDB tables?

Answer:

Single-table design can colocate related access patterns and reduce round-trips when the team can own generic keys and GSIs. Multiple tables are clearer when bounded contexts, IAM, or backup cadences differ. Interviewers want the trade-off: operational simplicity versus access-pattern efficiency—not a dogma.

Question 15
Interview Advanced
Question

How would you keep DynamoDB p99 latency low under bursty production traffic?

Answer:

Keep items small, prefer Query over Scan, use BatchGet/BatchWrite within limits, and cache hot keys. Provisioned tables need auto scaling plus enough headroom; on-demand still needs even partition spread. Isolate bursty workloads (analytics exports) from user-facing tables so one job cannot dominate p99.

Question 16
Interview Advanced
Question

What backup and restore practices would you set for a production DynamoDB table?

Answer:

Enable point-in-time recovery for accidental deletes and bad deploys, plus on-demand backups before schema-risking migrations. Practice restoring into a new table and cutting traffic over; never assume a backup works until you have timed an RTO drill. Document RPO/RTO separately from application-level undo.

Question 17
Interview Advanced
Question

How should DynamoDB Streams be used without coupling the write path to downstream systems?

Answer:

Have the write path persist the source of truth, then process INSERT/MODIFY/REMOVE records asynchronously with Lambda or Kinesis adapters. Use the sequence number and idempotent consumers so retries do not duplicate side effects. Avoid synchronous fan-out inside the original API call, which raises latency and failure blast radius.

Question 18
Interview Advanced
Question

How would you lock down a production DynamoDB table with IAM, encryption, and network controls?

Answer:

Grant least-privilege IAM actions scoped to table and index ARNs, require encryption at rest (AWS owned, KMS, or customer managed), and use TLS in transit. Prefer VPC endpoints over public internet from private subnets. Audit with CloudTrail and block wildcard resource policies in production accounts.

Question 19
Interview Advanced
Question

When would you use DynamoDB Global Tables, and what consistency caveats apply?

Answer:

Global Tables replicate across regions for low-latency local reads and regional failover. Replicas are eventually consistent across regions, so last-writer-wins can drop concurrent updates unless you add application-level conflict handling. Use them when locality or DR matters more than a single-region strong-consistency story.

Question 20
Interview Advanced
Question

Which CloudWatch and Contributor Insights signals indicate a poorly designed DynamoDB access pattern?

Answer:

Sustained ThrottledRequests, UserErrors, high ConsumedWriteCapacity on few keys, and SystemErrors during bursts all point at hot partitions or oversized items. Contributor Insights shows the hottest keys and most throttled operations. Fix the key design or cache before blindly raising provisioned capacity.

Practice with AI mock interviews

Run DynamoDB mock interviews with AI follow-ups, instant feedback, and analytics on AiLx.

Free to start · No credit card required