Database Reference
In-Depth Information
Data versioning and reconciliation
We know that DynamoDB is eventually consistent and it is write always, which means that
all data object updates need to go through all replicas asynchronously. In order to avoid any
data loss, DynamoDB keeps versions of objects. Later, these various versions get recon-
ciled to give a uniform response. To maintain this, DynamoDB creates new, immutable ob-
jects for new updates, which means a certain object can have multiple versions of it in a
DynamoDB system.
DynamoDB uses vector clocks to do the object versions and their conflict resolution. A
vector clock is a mechanism that helps in maintaining various versions of an object and in
resolving the conflicts. Let's understand the vector clock with an example. Suppose we
have two nodes say, N1 and N2, then for a particular object vector clock with [0,0], the first
zero stands for the object version on node N1 while the second 0 stands for the object ver-
sion on node N2. Now, node N1 writes to the object and updates its vector clock as [1,0]. If
the same thing happens with node N2, then it updates the vector clock as [0,1]. Meanwhile,
if due to some network issues, these two nodes go out of sync, then they would not be able
to understand each other's writes. This way, the conflicts are identified.
To resolve the conflicts, every data object keeps a context. If the same context is still
present at the time of the write, there is no harm in more writes, and you can proceed fur-
ther. In case of any conflict, we need to reconcile the data versions in order to maintain the
exact value for a given key. DynamoDB uses various reconciliation strategies to resolve the
conflicts:
• Logic-based reconciliation
• Time-based reconciliation
Logic-based reconciliation
In this method of reconciliation, the client who has requested the data object itself decides
whether it has got the exact version of the data object it was looking for. Amazon's shop-
ping cart service is a good example of logic-based reconciliation; here, in the event of any
conflict, the business logic itself reconciles the object and solves the conflict.
Time-based reconciliation
This is the simplest algorithm used for reconciliation of different versions of data objects in
DynamoDB. Here, the object version with the latest timestamp is supposed to be updated
Search WWH ::




Custom Search