Design Resilient Architectures
An AWS Lambda consumer updates a DynamoDB balance for each payment event, and failed deliveries or historical replays can deliver the same event again. Events have stable unique IDs, and processing must remain safe across concurrent invocations and crashes; which design meets these requirements?
Show the answer
Correct answerB. Atomically record each new event ID and update the balance in a DynamoDB transaction.
AWhy not this: A crash after updating the balance can cause a retry to apply the payment again.
BWhy this is right: A conditional insert and balance update in one transaction prevent duplicate effects and partial completion.
CWhy not this: Lambda memory is neither durable nor shared across concurrent execution environments.
DWhy not this: A crash after recording the ID can prevent a payment from ever updating the balance.
A transaction with a conditional event-ID insert makes the deduplication record and balance update atomic. Separate writes leave a crash window that can either lose an update or apply it twice.