DynamoDB

Transactions Interview Questions

Transactions 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

What do TransactWriteItems and TransactGetItems give you in DynamoDB?

Answer:

They apply a set of actions all-or-nothing across one or more items (and tables). Either every write/condition succeeds or none persist. Use them when two items must not diverge, not as a default wrapper for every Put.

Question 2
Interview Beginner
Question

What are the size limits of a DynamoDB transaction?

Answer:

A transaction can include up to 100 unique items and 4 MB of data. Duplicate the same item twice in one transaction and the request fails. Bulk jobs that touch thousands of rows need chunking or a different pattern, not one giant transaction.

Question 3
Interview Beginner
Question

What is a ConditionCheck action inside TransactWriteItems?

Answer:

It asserts an item state without changing it—for example “account still exists and status is ACTIVE”—so the accompanying Puts/Updates only commit if that check holds. Failed checks cancel the whole transaction. It is the transactional cousin of a single-item ConditionExpression.

Question 4
Interview Beginner
Question

Why do DynamoDB transactions cost more than single-item writes?

Answer:

Each item in a TransactWrite consumes extra WCUs (commonly 2× the usual write). You pay for atomicity and isolation. Wrapping a lone Put in a transaction is usually wasted money unless you needed a check against another item.

Question 5
Interview Beginner
Question

Can a DynamoDB transaction span more than one table?

Answer:

Yes. TransactWriteItems may include items from multiple tables in the same account and region. That is how you atomically update an orders table and an inventory table. Cross-region or cross-account atomicity is not provided.

Question 6
Interview Beginner
Question

When is a single-item Update with a ConditionExpression enough?

Answer:

When only one item’s correctness matters: decrement stock if quantity >= 1, or increment a version if it still matches. Conditions on one item are cheaper and simpler than TransactWrite. Reach for transactions when two or more items must move together.

Question 7
Interview Beginner
Question

What is the difference between a condition failure and a transaction conflict?

Answer:

A condition failure means your expression was false (insufficient funds). A conflict means another transaction touched an overlapping item at the same time. Both surface as TransactionCanceledException with different CancellationReasons; retry logic should not treat them the same.

Question 8
Interview Intermediate
Question

How would you implement a money transfer between two account items?

Answer:

TransactWrite: Update debit with condition balance >= amount, Update credit, optional ConditionCheck that both accounts are open. Use idempotency keys so retries do not double-transfer. Two independent Updates can credit without debiting if the process crashes between calls.

Question 9
Interview Intermediate
Question

What isolation do DynamoDB transactions provide for the items they touch?

Answer:

Serializable isolation among transactional writes on those items: readers of a committed transaction see all of it or none. Non-transactional reads can still be eventually consistent. Mixing heavy non-transactional writes on the same hot items increases conflicts.

Question 10
Interview Intermediate
Question

How should a client retry a failed DynamoDB transaction?

Answer:

Retry conflicts with jittered backoff; do not blindly retry condition failures without re-reading. Include a client request token or a ledger item so a successful retry after a timeout cannot apply twice. Infinite immediate retries on conflicts create a livelock on hot items.

Question 11
Interview Intermediate
Question

How do you inspect why TransactWriteItems was canceled?

Answer:

Read CancellationReasons on TransactionCanceledException: ConditionalCheckFailed, TransactionConflict, ValidationError, and the item that caused it. Logging only “transaction failed” hides whether you should retry, fix data, or reduce overlap. Reasons are the interview-level detail.

Question 12
Interview Intermediate
Question

Do transactional writes still update GSIs?

Answer:

Yes, projections happen as part of the committed write set. A throttled or limited GSI can still fail the transaction. Do not treat the GSI as a second transactional unique index; uniqueness belongs in conditions on base items.

Question 13
Interview Intermediate
Question

How do you reduce transaction conflicts on a hot item?

Answer:

Narrow the item’s write rate, split counters, or serialize that entity through a queue. Transactions isolate overlapping writes by failing one of them. If every request transacts on the same USER#1 balance item, conflicts become the product’s p99.

Question 14
Interview Intermediate
Question

Can you mix TransactWriteItems and a regular PutItem in one atomic request?

Answer:

No. Atomicity is only among the actions inside the transaction API call. A following PutItem can succeed after the transaction fails, or vice versa. Application flows that need both must put every item into the same TransactWriteItems request.

Question 15
Interview Advanced
Question

How would you model inventory reservation without holding a transaction open across user think time?

Answer:

Commit a short transaction that decrements stock and writes a RESERVED item with TTL, then confirm or cancel in a second transaction. Do not wait on a browser session inside one TransactWrite. Long-lived locks are not a DynamoDB primitive; expiry plus a state machine is.

Question 16
Interview Advanced
Question

When are transactions a poor fit for a high-throughput path?

Answer:

When you touch many items per request, wrap every write “just in case,” or serialize a celebrity item. Extra WCUs and conflict retries dominate p99. High-QPS append-only event logs almost never want a 100-item transaction per event.

Question 17
Interview Advanced
Question

How do transactional writes appear to DynamoDB Streams consumers?

Answer:

Each item change still emits its own stream record after commit; there is no single “transaction envelope” record. Consumers that must apply a multi-item business event atomically need a correlation id on the items or a separate outbox item. Designing for that avoids partial search updates.

Question 18
Interview Advanced
Question

How would you migrate from application-level two-phase commit to TransactWriteItems?

Answer:

Identify pairs that already must stay aligned, encode them as one transaction, and keep an idempotency ledger. Drop the prepare/commit tables once conflict rates and metrics look healthy. Half-migrated code that still does a lone write beside a transaction reintroduces the original race.

Question 19
Interview Advanced
Question

Why are DynamoDB transactions a bad bulk ETL tool?

Answer:

The 100-item and 4 MB caps, doubled WCUs, and conflict behavior make large copies slow and expensive. Use Import from S3, BatchWriteItem with backoff, or a warehouse pipeline. Transactions are for correctness of a business unit of work, not for loading last night’s dump.

Question 20
Interview Advanced
Question

How do you test concurrent transaction conflicts in CI?

Answer:

Run parallel workers against the same keys in a local or dedicated table and assert only one transfer wins and balances still sum. Include timeout-retry cases with idempotency keys. A single-threaded unit test of TransactWrite never reveals the cancellation path interviewers care about.

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