NoSQL in the cloud
Table
Data Model Concept
Item
Item
Item
Table
Data Model Concept
Item
Item
Item
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
DynamoDB is schema-less
each attribute defines it
max size 400kB
Data Model Concept
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Hash key
Hash key
Hash key
Hash keys:
Data Model Concept
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Hash key
Range keys:
Range key
Data Model Concept
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Hash key
Local secondary index:
Range key
Data Model Concept
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Attribute
Hash key
Global secondary index:
Range key
{
"day": "Monday",
"unreadEmails": 42,
"dayPhoto" : "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk",
"itemsOnMyDesk": [
"coffee Cup",
"telephone",
{
"pens": { "Quantity" : 3},
"pencils": { "Quantity" : 2},
"erasers": { "Quantity" : 1}
}
]
}
Number of items per write x 1KB
498 * 20 bytes / 1024 bytes / 4kB ~ 2,43 = 3 Read capacity units
498 * 20 bytes / 1024 bytes / 1kB ~ 9,73 = 10 Write capacity units
Partition 1
Partition 2
Partition N
Table
DynamoDB automatically partition data using hash key
considering size only
considering table read/write throughput
tableSizeInBytes / 10GB
readCapacity / 3000 + writeCapacity / 1000
1) RCU: 2000 and WCU: 1000
2000 / 3000 + 1000 / 1000 = 1.(3) ==> 2 partitions
2) Table size = 1TB
1000 GB / 10 GB = 10 partitions,
then throughput based on example 1:
200 RCU and 100 WCU per partition
How hash key may interfere
There are 2 possibilities to create a DynamoDB table
via AWS Web console
via API
DynamoDB dynamoDB = new DynamoDB(new AmazonDynamoDBClient(
new ProfileCredentialsProvider()));
CreateTableRequest request = new CreateTableRequest()
.withTableName(tableName)
.withKeySchema(keySchema)
.withAttributeDefinitions(attributeDefinitions)
.withProvisionedThroughput(new ProvisionedThroughput()
.withReadCapacityUnits(5L)
.withWriteCapacityUnits(6L));
Table table = dynamoDB.createTable(request);
ACID in DynamoDB world
Krzysztof Folwarczny
ImmobilienScout24 Tribe
pokój 5.56