A company uses DynamoDB global tables in two AWS Regions with strong consistency reads. They observe occasional write conflicts that are not being resolved automatically. The application uses DynamoDBMapper with optimistic locking. What should the DevOps engineer do to ensure conflict resolution?
Trap 1: Implement a custom conflict resolution using DynamoDB Streams and…
DynamoDB global tables already provide last-writer-wins (LWW) conflict resolution per item, so adding a custom Streams + Lambda resolver introduces unnecessary complexity. A custom resolver must handle duplicate event delivery, ordering, and potential write-backs that trigger the Stream again, creating loops. It also adds latency and cost, and it does not address the fact that concurrent writes to the same item still need a deterministic policy—built-in LWW is the default and is adequate for typical workloads.
Trap 2: Switch to eventual consistency reads to reduce conflicts.
Eventual consistency reads control how fresh a read result is, not how conflicting writes are resolved. In global tables, replication is asynchronous, and conflicts are resolved at write time using LWW based on the replica timestamp, independent of the read consistency setting. Switching from strongly consistent to eventually consistent reads only risks returning stale data, but it does not prevent or reconcile conflicting updates to the same item.
Trap 3: Add a third global table region to increase redundancy.
Adding a third global table region increases replication paths and creates more endpoints where concurrent writes can originate, potentially increasing the frequency of write-write conflicts. Redundancy improves availability and durability across regions, but it does not alter the underlying LWW conflict resolution mechanism—every conflict is still resolved by the same timestamp-based rule. More regions mean more replication latency and more chances for different writers to race, not a reduction in conflicts.
- A
Implement a custom conflict resolution using DynamoDB Streams and AWS Lambda.
Why wrong: DynamoDB global tables already provide last-writer-wins (LWW) conflict resolution per item, so adding a custom Streams + Lambda resolver introduces unnecessary complexity. A custom resolver must handle duplicate event delivery, ordering, and potential write-backs that trigger the Stream again, creating loops. It also adds latency and cost, and it does not address the fact that concurrent writes to the same item still need a deterministic policy—built-in LWW is the default and is adequate for typical workloads.
- B
Switch to eventual consistency reads to reduce conflicts.
Why wrong: Eventual consistency reads control how fresh a read result is, not how conflicting writes are resolved. In global tables, replication is asynchronous, and conflicts are resolved at write time using LWW based on the replica timestamp, independent of the read consistency setting. Switching from strongly consistent to eventually consistent reads only risks returning stale data, but it does not prevent or reconcile conflicting updates to the same item.
- C
Add a third global table region to increase redundancy.
Why wrong: Adding a third global table region increases replication paths and creates more endpoints where concurrent writes can originate, potentially increasing the frequency of write-write conflicts. Redundancy improves availability and durability across regions, but it does not alter the underlying LWW conflict resolution mechanism—every conflict is still resolved by the same timestamp-based rule. More regions mean more replication latency and more chances for different writers to race, not a reduction in conflicts.
- D
Use conditional writes with a version number attribute to ensure updates are applied only to the latest version.
By including a version number attribute in a conditional write (e.g., `SET version = version + 1 ... WHERE version = :expected`), the application uses optimistic locking to guarantee that an update is applied only when the client's expected version matches the current item version. If the condition fails, the client can re-read the latest item, merge or retry the update, and thus avoid overwriting concurrent changes. This approach aligns with DynamoDB's LWW because the version check ensures a deterministic, ordered update sequence, preventing stale writes from triumphing solely due to last-writer timestamp.