Database Reference
In-Depth Information
Distributed locking
To demonstrate the idea of distributed locking, let us relate it to something that program-
mers use commonly to share it among your project team. Consider Team Foundation
Serve r ( TFS ) or SVN (Apache Subversion), which we commonly use to manage the team's
program code. If you don't get what we are talking about, please refer to ht-
tp://en.wikipedia.org/wiki/Apache_Subversion . In both these pieces of software, any num-
ber of permitted team members can read a code and download the latest code to his/her loc-
al machine and start editing. After editing the program, one programmer synchronizes his/
her program with the SVN repository. What this means is that all other programmers are
making changes to the obsolete program. So, if any other programmer tries to commit his/
her code, SVN issues a warning and will not permit the user to do so.
As far as DynamoDB is concerned, why do we need distributed locking? It's because, once
we start using the DynamoDB table, everything is fine. Apart from us, no one is going to
access it. But, consider an application backed up by DynamoDB. Are we sure that only one
user will use the application and perform write operations at one time? We cannot predict
that. This is the reason why we need to lock data just in case the same data is accessed by
another client at the same time. DynamoDB provides this distributed locking through a
mechanism called optimistic locking, which we will discuss at the end of this chapter. First,
let us observe a real-time example where locking is important.
Let's take a look at some real-life examples. Let's wind the clocks back a decade or a
couple of years. Imagine that we are back at school and having a look at the following col-
or mixer:
The RGB color chart says that if we mix the green and blue color paint or dye, we will get
the color cyan, and we can mix two colors as shown in the preceding diagram to get the ne-
cessary color. There is a family with three members, and each member is given one of the
primary colors (red, blue, and green). They are asked to prepare the white paint to paint
Search WWH ::




Custom Search