Database Reference
In-Depth Information
Solutions available to solve distributed writes
DynamoDB already has two solutions (so far) to synchronize the writes of multiple users or
clients. Let us list those solutions:
• Adding the client requests to Simple Queue Service ( SQS )
• Using of conditional writes (as discussed in the Operations in DynamoDB section
in Chapter 6 , Working with the DynamoDB API )
Tip
SQS allows us to store messages in a highly reliable, scalable queue, which is hos-
ted by AWS as a service. In a distributed and scalable environment, all the mes-
sages from applications might not directly be destined to be stored in a database. In
order to set the destination for these messages, they need to be added to a reliable
queue such as SQS.
The first solution is a little advanced, because it requires knowledge of Amazon SQS. In
this, all the DynamoDB requests will be redirected to SQS. There is an internal mechanism
in SQS that will not allow multiple readers on the same data. Because of this, until the first
client is done with his work, no one else can read the data. This way, we can avoid concur-
rent writing of data.
Let us see the syntax of the UpdateItem request, otherwise we might not be sailing in
the same boat:
{
"TableName": "Tbl_Book",
"Key": {
"BookTitle": { "S": "SCJP" },
"Author": { "S": "Kathy" } },
"AttributeUpdates": {
"Language": {
"Value": { "SS": ["English","German","Latin"]},
"Action": "PUT" } },
"ReturnValues": "ALL_NEW"
}
Search WWH ::




Custom Search