SlideShare a Scribd company logo
Deep dive on DynamoDB to create scalable app
Eduardo Horai
AWS Solutions Architect
1

What is
DynamoDB?
DynamoDB is a managed
NoSQL database service.
Store and retrieve any amount of data.
	


Serve any level of request traffic.
Without the operational burden.
Consistent, predictable performance.
Single digit millisecond latency.
	


Backed on solid-state drives.
Flexible data model.
Key/attribute pairs. No schema required.
	


Easy to create. Easy to adjust.
Seamless scalability.
No table size limits. Unlimited storage.
	


No downtime.
Durable.
Consistent, disk only writes.
	


Replication across data centers and availability zones.
Focus on your app.
Provisioned throughput.
Reserve IOPS for reads and writes.
	


Scale up for down at any time.
Pay per capacity unit.
Priced per hour of provisioned throughput.
Write throughput.
Size of item x writes per second
>= 1KB
Consistent writes.
Atomic increment and decrement.
Optimistic concurrency control: conditional writes.
Transactions.
Item level transactions only.
Puts, updates and deletes are ACID.
Strong or eventual consistency

Read throughput.
Strong or eventual consistency

Read throughput.
Provisioned units = size of item x reads per second
>= 4KB
Strong or eventual consistency

Read throughput.
Provisioned units = size of item x reads per second
2
Strong or eventual consistency

Read throughput.
Same latency expectations.
Mix and match at ‘read time’.
Provisioned throughput is
managed by DynamoDB.
Data is partitioned and
managed by DynamoDB.
Partitioning
•  DynamoDB automatically partitions data by the hash key
–  Hash key spreads data & workload across partitions

•  Auto-Partitioning driven by:
–  Data set size
–  Provisioned Throughput

•  Tip: large number of unique hash keys and uniform
distribution of workload across hash keys lends well to
massive scale!
Indexed data storage.
Tiered bandwidth pricing:
aws.amazon.com/dynamodb/pricing
Reserved capacity.
Up to 53% for 1 year reservation.
Up to 76% for 3 year reservation.
Authentication.
Session based to minimize latency.
Uses the Amazon Security T
oken Service.
	


Handled by AWS SDKs.
Integrates with IAM.
Monitoring.
CloudWatch metrics:
latency, consumed read and write throughput,
errors and throttling.
Libraries, mappers and mocks.
ColdFusion, Django, Erlang, Java, .Net,
Node.js, Perl, PHP Python, Ruby
,
	

	


	


http://j.mp/dynamodb-libs
2

NoSQL Data
Modeling
id = 100

date =
2012-05-16-09-00-10

total = 25.00

id = 101

date =
2012-05-15-15-00-11

total = 35.00

id = 101

date =
2012-05-16-12-00-10

total = 100.00
T
able

id = 100

date =
2012-05-16-09-00-10

total = 25.00

id = 101

date =
2012-05-15-15-00-11

total = 35.00

id = 101

date =
2012-05-16-12-00-10

total = 100.00
id = 100

date =
2012-05-16-09-00-10

total = 25.00

id = 101

date =
2012-05-15-15-00-11

total = 35.00

id = 101

date =
2012-05-16-12-00-10

total = 100.00

Item
date =
2012-05-16-09-00-10

total = 25.00

id = 101

date =
2012-05-15-15-00-11

total = 35.00

id = 101

date =
2012-05-16-12-00-10

total = 100.00

id = 100

Attribute
Where is the schema?
T
ables do not require a formal schema.
	


Items are an arbitrarily sized hash.
Indexing.
Items are indexed by primary and secondary keys.
Primary keys can be composite.
Secondary keys are local to the table.
ID

Date

T
otal
Hash key

ID

Date

T
otal
Hash key

Range key

ID

Date

Composite primary key

T
otal
Hash key

Range key

Secondary range key

ID

Date

T
otal
Programming DynamoDB.
Small but perfectly formed API.
CreateTable

PutItem

UpdateTable

GetItem

DeleteTable

UpdateItem

DescribeTable

DeleteItem

ListTables
Query
Scan

BatchGetItem
BatchWriteItem
CreateTable

PutItem

UpdateTable

GetItem

DeleteTable

UpdateItem

DescribeTable

DeleteItem

ListTables
Query
Scan

BatchGetItem
BatchWriteItem
CreateTable

PutItem

UpdateTable

GetItem

DeleteTable

UpdateItem

DescribeTable

DeleteItem

ListTables
Query
Scan

BatchGetItem
BatchWriteItem
Conditional updates.
PutItem, UpdateItem, DeleteItem can take
optional conditions for operation.
	


	


UpdateItem performs atomic increments.
One API call, multiple items
BatchGet returns multiple items by key.
BatchWrite performs up to 25 put or delete operations.
	


	


Throughput is measured by IO, not API calls.
CreateTable

PutItem

UpdateTable

GetItem

DeleteTable

UpdateItem

DescribeTable

DeleteItem

ListTables
Query
Scan

BatchGetItem
BatchWriteItem
Query vs Scan
Query returns items by key.
	


	


Scan reads the whole table sequentially.
Query patterns
Retrieve all items by hash key.
	


	

	

	


Range key conditions:
==, <, >, >=, <=, begins with, between.
	


	

	

	


Counts. T and bottom n values.
op
Paged responses.
3

Example
…
AmazonDynamoDBClient dynamoDB; = new AmazonDynamoDBClient(	

new ClasspathPropertiesFileCredentialsProvider());	

	

dynamoDB.setRegion(Region.getRegion(Regions. SA_EAST_1));
Players
user_id =
mza

location =
Cambridge

joined =
2011-07-04

user_id =
jeffbarr

location =
Seattle

joined =
2012-01-20

user_id =
werner

location =
Worldwide

joined =
2011-05-15
CreateTableRequest createPlayersTable = 	

new CreateTableRequest().withTableName("Players")	

.withKeySchema(new KeySchemaElement().withAttributeName("user_id")	

.withKeyType(KeyType.HASH))	

.withAttributeDefinitions(newAttributeDefinition()	

.withAttributeName("user_id").withAttributeType(ScalarAttributeType.S))	

.withProvisionedThroughput(new ProvisionedThroughput()	

.withReadCapacityUnits(10L)	

.withWriteCapacityUnits(10L));	

	

	

dynamoDB.createTable(createPlayersTable);
Players
user_id =
mza

location =
Cambridge

joined =
2011-07-04

user_id =
jeffbarr

location =
Seattle

joined =
2012-01-20

user_id =
werner

location =
Worldwide

joined =
2011-05-15

user_id =
mza

game =
angry-birds

score =
11,000

user_id =
mza

game =
tetris

score =
1,223,000

user_id =
werner

game =
bejewelled

score =
55,000

Scores
CreateTableRequest createScoresTable = 	

new CreateTableRequest().withTableName(”Scores")	

.withKeySchema(new KeySchemaElement().withAttributeName("user_id")	

.withKeyType(KeyType.HASH))	

.withAttributeDefinitions(newAttributeDefinition()	

.withAttributeName("user_id").withAttributeType(ScalarAttributeType.S))
.withKeySchema(new KeySchemaElement().withAttributeName(”game")	

.withKeyType(KeyType.RANGE))	

.withAttributeDefinitions(newAttributeDefinition()	

.withAttributeName(”game").withAttributeType(ScalarAttributeType.S))	

.withProvisionedThroughput(new ProvisionedThroughput()	

.withReadCapacityUnits(100L)	

.withWriteCapacityUnits(100L));
Players
user_id =
mza

location =
Cambridge

joined =
2011-07-04

user_id =
jeffbarr

location =
Seattle

joined =
2012-01-20

user_id =
werner

location =
Worldwide

joined =
2011-05-15

Leader boards

Scores
user_id =
mza

game =
angry-birds

score =
11,000

game =
angry-birds

score =
11,000

user_id =
mza

user_id =
mza

game =
tetris

score =
1,223,000

game =
tetris

score =
1,223,000

user_id =
mza

user_id =
werner

game =
bejewelled

score =
55,000

game =
tetris

score =
9,000,000

user_id =
jeffbarr
CreateTableRequest createLeaderBoardsTable = 	

new CreateTableRequest().withTableName(”LeaderBoards")	

.withKeySchema(new KeySchemaElement().withAttributeName(”game")	

.withKeyType(KeyType.HASH))	

.withAttributeDefinitions(newAttributeDefinition()	

.withAttributeName(”game").withAttributeType(ScalarAttributeType.S))	

.withKeySchema(new KeySchemaElement().withAttributeName(”score")	

.withKeyType(KeyType.RANGE))	

.withAttributeDefinitions(newAttributeDefinition()	

.withAttributeName(”score").withAttributeType(ScalarAttributeType.N))	

.withProvisionedThroughput(new ProvisionedThroughput()	

.withReadCapacityUnits(50L)	

.withWriteCapacityUnits(50L));
Players
user_id =
mza

location =
Cambridge

joined =
2011-07-04

user_id =
jeffbarr

location =
Seattle

joined =
2012-01-20

user_id =
werner

location =
Worldwide

joined =
2011-05-15

Query for user

Leader boards

Scores
user_id =
mza

game =
angry-birds

score =
11,000

game =
angry-birds

score =
11,000

user_id =
mza

user_id =
mza

game =
tetris

score =
1,223,000

game =
tetris

score =
1,223,000

user_id =
mza

user_id =
werner

game =
bejewelled

score =
55,000

game =
tetris

score =
9,000,000

user_id =
jeffbarr
Map<String, Condition> keyConditions = new HashMap<String, Condition>();
keyConditions.put("user_id", new Condition()	

.withComparisonOperator(ComparisonOperator.EQ.toString())	

.withAttributeValueList(new AttributeValue().withS("mza")));	

	

QueryRequest queryRequest = new QueryRequest()	

.withTableName("Players")	

.withKeyConditions(keyConditions);	

	

	

QueryResult result = dynamoDB.query(queryRequest);	

for (Map<String, AttributeValue> item : result.getItems()) {	

printItem(item);	

}
Players
user_id =
mza

location =
Cambridge

joined =
2011-07-04

user_id =
jeffbarr

location =
Seattle

joined =
2012-01-20

user_id =
werner

location =
Worldwide

joined =
2011-05-15

Query for scores
by user

Leader boards

Scores
user_id =
mza

game =
angry-birds

score =
11,000

game =
angry-birds

score =
11,000

user_id =
mza

user_id =
mza

game =
tetris

score =
1,223,000

game =
tetris

score =
1,223,000

user_id =
mza

user_id =
werner

game =
bejewelled

score =
55,000

game =
tetris

score =
9,000,000

user_id =
jeffbarr
Map<String, Condition> keyConditions = new HashMap<String, Condition>();
keyConditions.put("user_id", new Condition()	

.withComparisonOperator(ComparisonOperator.EQ.toString())	

.withAttributeValueList(new AttributeValue().withS("mza")));	

	

QueryRequest queryRequest = new QueryRequest()	

.withTableName(”Scores")	

.withAttributesToGet(”score”, “game”)	

.withKeyConditions(keyConditions);	

	

	

QueryResult result = dynamoDB.query(queryRequest);	

for (Map<String, AttributeValue> item : result.getItems()) {	

printItem(item);	

}
Players
user_id =
mza

location =
Cambridge

joined =
2011-07-04

user_id =
jeffbarr

location =
Seattle

joined =
2012-01-20

user_id =
werner

location =
Worldwide

joined =
2011-05-15

Query for scores
by user, game

Leader boards

Scores
user_id =
mza

game =
angry-birds

score =
11,000

game =
angry-birds

score =
11,000

user_id =
mza

user_id =
mza

game =
tetris

score =
1,223,000

game =
tetris

score =
1,223,000

user_id =
mza

user_id =
werner

game =
bejewelled

score =
55,000

game =
tetris

score =
9,000,000

user_id =
jeffbarr
Map<String, Condition> keyConditions = new HashMap<String, Condition>();
keyConditions.put("user_id", new Condition()	

.withComparisonOperator(ComparisonOperator.EQ.toString())	

.withAttributeValueList(new AttributeValue().withS("mza")));	

keyConditions.put(”game", new Condition()	

.withComparisonOperator(ComparisonOperator.EQ.toString())	

.withAttributeValueList(new AttributeValue().withS(”tetris")));	

	

QueryRequest queryRequest = new QueryRequest()	

.withTableName(”Scores")	

.withKeyConditions(keyConditions);	

	

	

QueryResult result = dynamoDB.query(queryRequest);	

for (Map<String, AttributeValue> item : result.getItems()) {	

printItem(item);	

}
Players
user_id =
mza

location =
Cambridge

joined =
2011-07-04

user_id =
jeffbarr

location =
Seattle

joined =
2012-01-20

user_id =
werner

location =
Worldwide

joined =
2011-05-15

High scores by game

Leader boards

Scores
user_id =
mza

game =
angry-birds

score =
11,000

game =
angry-birds

score =
11,000

user_id =
mza

user_id =
mza

game =
tetris

score =
1,223,000

game =
tetris

score =
1,223,000

user_id =
mza

user_id =
werner

game =
bejewelled

score =
55,000

game =
tetris

score =
9,000,000

user_id =
jeffbarr
Map<String, Condition> keyConditions = new HashMap<String, Condition>();
keyConditions.put(”game", new Condition()	

.withComparisonOperator(ComparisonOperator.EQ.toString())	

.withAttributeValueList(new AttributeValue().withS(”tetris")));	

	

QueryRequest queryRequest = new QueryRequest()	

.withTableName(”LeaderBoards")	

.withKeyConditions(keyConditions)	

. withScanIndexForward(false);	

	

	

QueryResult result = dynamoDB.query(queryRequest);	

for (Map<String, AttributeValue> item : result.getItems()) {	

printItem(item);	

}
Players
user_id =
mza

location =
Cambridge

joined =
2011-07-04

user_id =
jeffbarr

location =
Seattle

joined =
2012-01-20

user_id =
werner

location =
Worldwide

joined =
2011-05-15

Insert Players

Leader boards

Scores
user_id =
mza

game =
angry-birds

score =
11,000

game =
angry-birds

score =
11,000

user_id =
mza

user_id =
mza

game =
tetris

score =
1,223,000

game =
tetris

score =
1,223,000

user_id =
mza

user_id =
werner

game =
bejewelled

score =
55,000

game =
tetris

score =
9,000,000

user_id =
jeffbarr
Map<String, AttributeValue> itemPlayer = 	

new HashMap<String, AttributeValue>();	

	

itemPlayer.put("user_id", new AttributeValue("eduardohorai"));	

itemPlayer.put("location", new AttributeValue("Sao Paulo"));	

itemPlayer.put("joined", new AttributeValue("27/01/2013"));	

	

PutItemRequest putItemRequest = 	

new PutItemRequest("Players", itemPlayer);	

	

PutItemResult putItemResult = dynamoDB.putItem(putItemRequest);
Players
user_id =
mza

location =
Cambridge

joined =
2011-07-04

user_id =
jeffbarr

location =
Seattle

joined =
2012-01-20

user_id =
werner

location =
Worldwide

joined =
2011-05-15

Increase writes/reads
on Scores!!!!!

Leader boards

Scores
user_id =
mza

game =
angry-birds

score =
11,000

game =
angry-birds

score =
11,000

user_id =
mza

user_id =
mza

game =
tetris

score =
1,223,000

game =
tetris

score =
1,223,000

user_id =
mza

user_id =
werner

game =
bejewelled

score =
55,000

game =
tetris

score =
9,000,000

user_id =
jeffbarr
UpdateTableRequest updateTableRequest = new UpdateTableRequest()	

.withTableName("Scores")	

.withProvisionedThroughput(new ProvisionedThroughput()	

.withReadCapacityUnits(200L)	

.withWriteCapacityUnits(200L));	

	

UpdateTableResult result = 	

dynamoDB.updateTable(updateTableRequest);
4

Using
AWS Console
Links
§  aws.amazon.com/dynamodb	
  
§  aws.typepad.com/brasil/	
  
§  aws.typepad.com	
  
§  awshub.com.br	
  
§  ehorai@amazon.com	
  
Questions?
Learn More:
aws.amazon.com/dynamodb
Obrigado!
Learn More:
aws.amazon.com/dynamodb

More Related Content

Similar to DynamoDB Deep Dive (20)

PPTX
DynamoDB Database Integration.pptx it's dynamodb databse related stufs
yashconestoga
 
PDF
Amazon DynamoDB
Kriti Katyayan
 
ZIP
Gluecon 2012 - DynamoDB
Jeff Douglas
 
KEY
DynamoDB Gluecon 2012
Appirio
 
DOCX
Dynamo db pros and cons
Saniya Khalsa
 
PPTX
Dynamo db
Parag Patil
 
PDF
Deep Dive into DynamoDB
AWS Germany
 
PPTX
Dynamo vs Mongo
Amar Das
 
PPTX
Compare DynamoDB vs. MongoDB
Amar Das
 
PPT
CO3-Session-6(AmazonDynamoDB).ppt
AbhignaReddy30
 
PDF
AWS DynamoDB
Suman Debnath
 
PDF
AWS DynamoDB
Aléx Carvalho
 
PDF
2017 AWS DB Day | Amazon DynamoDB 서비스, 개요 및 신규 기능 소개
Amazon Web Services Korea
 
PDF
No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ...
AWS Summits
 
PDF
Intro to database_services_fg_aws_summit_2014
Amazon Web Services LATAM
 
PDF
An Introduction to Amazon’s DynamoDB
Knoldus Inc.
 
PPTX
Aws Summit Berlin 2013 - Understanding database options on AWS
AWS Germany
 
PDF
Conhecendo o DynamoDB
Amazon Web Services LATAM
 
PPTX
AWS SSA Webinar 33 - Getting started with databases on AWS Amazon DynamoDB
Cobus Bernard
 
PPTX
DBMbsbsiisnsbshsjsbshsjwnsnS_PPT final.pptx
aryanrajeshjadhao
 
DynamoDB Database Integration.pptx it's dynamodb databse related stufs
yashconestoga
 
Amazon DynamoDB
Kriti Katyayan
 
Gluecon 2012 - DynamoDB
Jeff Douglas
 
DynamoDB Gluecon 2012
Appirio
 
Dynamo db pros and cons
Saniya Khalsa
 
Dynamo db
Parag Patil
 
Deep Dive into DynamoDB
AWS Germany
 
Dynamo vs Mongo
Amar Das
 
Compare DynamoDB vs. MongoDB
Amar Das
 
CO3-Session-6(AmazonDynamoDB).ppt
AbhignaReddy30
 
AWS DynamoDB
Suman Debnath
 
AWS DynamoDB
Aléx Carvalho
 
2017 AWS DB Day | Amazon DynamoDB 서비스, 개요 및 신규 기능 소개
Amazon Web Services Korea
 
No Hassle NoSQL - Amazon DynamoDB & Amazon DocumentDB | AWS Summit Tel Aviv ...
AWS Summits
 
Intro to database_services_fg_aws_summit_2014
Amazon Web Services LATAM
 
An Introduction to Amazon’s DynamoDB
Knoldus Inc.
 
Aws Summit Berlin 2013 - Understanding database options on AWS
AWS Germany
 
Conhecendo o DynamoDB
Amazon Web Services LATAM
 
AWS SSA Webinar 33 - Getting started with databases on AWS Amazon DynamoDB
Cobus Bernard
 
DBMbsbsiisnsbshsjsbshsjwnsnS_PPT final.pptx
aryanrajeshjadhao
 

More from Amazon Web Services LATAM (20)

PPTX
AWS para terceiro setor - Sessão 1 - Introdução à nuvem
Amazon Web Services LATAM
 
PPTX
AWS para terceiro setor - Sessão 2 - Armazenamento e Backup
Amazon Web Services LATAM
 
PPTX
AWS para terceiro setor - Sessão 3 - Protegendo seus dados.
Amazon Web Services LATAM
 
PPTX
AWS para terceiro setor - Sessão 1 - Introdução à nuvem
Amazon Web Services LATAM
 
PPTX
AWS para terceiro setor - Sessão 2 - Armazenamento e Backup
Amazon Web Services LATAM
 
PPTX
AWS para terceiro setor - Sessão 3 - Protegendo seus dados.
Amazon Web Services LATAM
 
PPTX
Automatice el proceso de entrega con CI/CD en AWS
Amazon Web Services LATAM
 
PPTX
Automatize seu processo de entrega de software com CI/CD na AWS
Amazon Web Services LATAM
 
PPTX
Cómo empezar con Amazon EKS
Amazon Web Services LATAM
 
PPTX
Como começar com Amazon EKS
Amazon Web Services LATAM
 
PPTX
Ransomware: como recuperar os seus dados na nuvem AWS
Amazon Web Services LATAM
 
PPTX
Ransomware: cómo recuperar sus datos en la nube de AWS
Amazon Web Services LATAM
 
PPTX
Ransomware: Estratégias de Mitigação
Amazon Web Services LATAM
 
PPTX
Ransomware: Estratégias de Mitigación
Amazon Web Services LATAM
 
PPTX
Aprenda a migrar y transferir datos al usar la nube de AWS
Amazon Web Services LATAM
 
PPTX
Aprenda como migrar e transferir dados ao utilizar a nuvem da AWS
Amazon Web Services LATAM
 
PPTX
Cómo mover a un almacenamiento de archivos administrados
Amazon Web Services LATAM
 
PPTX
Simplifique su BI con AWS
Amazon Web Services LATAM
 
PPTX
Simplifique o seu BI com a AWS
Amazon Web Services LATAM
 
PPTX
Os benefícios de migrar seus workloads de Big Data para a AWS
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 1 - Introdução à nuvem
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 2 - Armazenamento e Backup
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 3 - Protegendo seus dados.
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 1 - Introdução à nuvem
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 2 - Armazenamento e Backup
Amazon Web Services LATAM
 
AWS para terceiro setor - Sessão 3 - Protegendo seus dados.
Amazon Web Services LATAM
 
Automatice el proceso de entrega con CI/CD en AWS
Amazon Web Services LATAM
 
Automatize seu processo de entrega de software com CI/CD na AWS
Amazon Web Services LATAM
 
Cómo empezar con Amazon EKS
Amazon Web Services LATAM
 
Como começar com Amazon EKS
Amazon Web Services LATAM
 
Ransomware: como recuperar os seus dados na nuvem AWS
Amazon Web Services LATAM
 
Ransomware: cómo recuperar sus datos en la nube de AWS
Amazon Web Services LATAM
 
Ransomware: Estratégias de Mitigação
Amazon Web Services LATAM
 
Ransomware: Estratégias de Mitigación
Amazon Web Services LATAM
 
Aprenda a migrar y transferir datos al usar la nube de AWS
Amazon Web Services LATAM
 
Aprenda como migrar e transferir dados ao utilizar a nuvem da AWS
Amazon Web Services LATAM
 
Cómo mover a un almacenamiento de archivos administrados
Amazon Web Services LATAM
 
Simplifique su BI con AWS
Amazon Web Services LATAM
 
Simplifique o seu BI com a AWS
Amazon Web Services LATAM
 
Os benefícios de migrar seus workloads de Big Data para a AWS
Amazon Web Services LATAM
 
Ad

Recently uploaded (20)

PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Digital Circuits, important subject in CS
contactparinay1
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Ad

DynamoDB Deep Dive

  • 1. Deep dive on DynamoDB to create scalable app Eduardo Horai AWS Solutions Architect
  • 3. DynamoDB is a managed NoSQL database service. Store and retrieve any amount of data. Serve any level of request traffic.
  • 5. Consistent, predictable performance. Single digit millisecond latency. Backed on solid-state drives.
  • 6. Flexible data model. Key/attribute pairs. No schema required. Easy to create. Easy to adjust.
  • 7. Seamless scalability. No table size limits. Unlimited storage. No downtime.
  • 8. Durable. Consistent, disk only writes. Replication across data centers and availability zones.
  • 10. Provisioned throughput. Reserve IOPS for reads and writes. Scale up for down at any time.
  • 11. Pay per capacity unit. Priced per hour of provisioned throughput.
  • 12. Write throughput. Size of item x writes per second >= 1KB
  • 13. Consistent writes. Atomic increment and decrement. Optimistic concurrency control: conditional writes.
  • 14. Transactions. Item level transactions only. Puts, updates and deletes are ACID.
  • 15. Strong or eventual consistency Read throughput.
  • 16. Strong or eventual consistency Read throughput. Provisioned units = size of item x reads per second >= 4KB
  • 17. Strong or eventual consistency Read throughput. Provisioned units = size of item x reads per second 2
  • 18. Strong or eventual consistency Read throughput. Same latency expectations. Mix and match at ‘read time’.
  • 20. Data is partitioned and managed by DynamoDB.
  • 21. Partitioning •  DynamoDB automatically partitions data by the hash key –  Hash key spreads data & workload across partitions •  Auto-Partitioning driven by: –  Data set size –  Provisioned Throughput •  Tip: large number of unique hash keys and uniform distribution of workload across hash keys lends well to massive scale!
  • 22. Indexed data storage. Tiered bandwidth pricing: aws.amazon.com/dynamodb/pricing
  • 23. Reserved capacity. Up to 53% for 1 year reservation. Up to 76% for 3 year reservation.
  • 24. Authentication. Session based to minimize latency. Uses the Amazon Security T oken Service. Handled by AWS SDKs. Integrates with IAM.
  • 25. Monitoring. CloudWatch metrics: latency, consumed read and write throughput, errors and throttling.
  • 26. Libraries, mappers and mocks. ColdFusion, Django, Erlang, Java, .Net, Node.js, Perl, PHP Python, Ruby , http://j.mp/dynamodb-libs
  • 28. id = 100 date = 2012-05-16-09-00-10 total = 25.00 id = 101 date = 2012-05-15-15-00-11 total = 35.00 id = 101 date = 2012-05-16-12-00-10 total = 100.00
  • 29. T able id = 100 date = 2012-05-16-09-00-10 total = 25.00 id = 101 date = 2012-05-15-15-00-11 total = 35.00 id = 101 date = 2012-05-16-12-00-10 total = 100.00
  • 30. id = 100 date = 2012-05-16-09-00-10 total = 25.00 id = 101 date = 2012-05-15-15-00-11 total = 35.00 id = 101 date = 2012-05-16-12-00-10 total = 100.00 Item
  • 31. date = 2012-05-16-09-00-10 total = 25.00 id = 101 date = 2012-05-15-15-00-11 total = 35.00 id = 101 date = 2012-05-16-12-00-10 total = 100.00 id = 100 Attribute
  • 32. Where is the schema? T ables do not require a formal schema. Items are an arbitrarily sized hash.
  • 33. Indexing. Items are indexed by primary and secondary keys. Primary keys can be composite. Secondary keys are local to the table.
  • 37. Hash key Range key Secondary range key ID Date T otal
  • 38. Programming DynamoDB. Small but perfectly formed API.
  • 42. Conditional updates. PutItem, UpdateItem, DeleteItem can take optional conditions for operation. UpdateItem performs atomic increments.
  • 43. One API call, multiple items BatchGet returns multiple items by key. BatchWrite performs up to 25 put or delete operations. Throughput is measured by IO, not API calls.
  • 45. Query vs Scan Query returns items by key. Scan reads the whole table sequentially.
  • 46. Query patterns Retrieve all items by hash key. Range key conditions: ==, <, >, >=, <=, begins with, between. Counts. T and bottom n values. op Paged responses.
  • 48.
  • 49. AmazonDynamoDBClient dynamoDB; = new AmazonDynamoDBClient( new ClasspathPropertiesFileCredentialsProvider()); dynamoDB.setRegion(Region.getRegion(Regions. SA_EAST_1));
  • 50. Players user_id = mza location = Cambridge joined = 2011-07-04 user_id = jeffbarr location = Seattle joined = 2012-01-20 user_id = werner location = Worldwide joined = 2011-05-15
  • 51. CreateTableRequest createPlayersTable = new CreateTableRequest().withTableName("Players") .withKeySchema(new KeySchemaElement().withAttributeName("user_id") .withKeyType(KeyType.HASH)) .withAttributeDefinitions(newAttributeDefinition() .withAttributeName("user_id").withAttributeType(ScalarAttributeType.S)) .withProvisionedThroughput(new ProvisionedThroughput() .withReadCapacityUnits(10L) .withWriteCapacityUnits(10L)); dynamoDB.createTable(createPlayersTable);
  • 52. Players user_id = mza location = Cambridge joined = 2011-07-04 user_id = jeffbarr location = Seattle joined = 2012-01-20 user_id = werner location = Worldwide joined = 2011-05-15 user_id = mza game = angry-birds score = 11,000 user_id = mza game = tetris score = 1,223,000 user_id = werner game = bejewelled score = 55,000 Scores
  • 53. CreateTableRequest createScoresTable = new CreateTableRequest().withTableName(”Scores") .withKeySchema(new KeySchemaElement().withAttributeName("user_id") .withKeyType(KeyType.HASH)) .withAttributeDefinitions(newAttributeDefinition() .withAttributeName("user_id").withAttributeType(ScalarAttributeType.S)) .withKeySchema(new KeySchemaElement().withAttributeName(”game") .withKeyType(KeyType.RANGE)) .withAttributeDefinitions(newAttributeDefinition() .withAttributeName(”game").withAttributeType(ScalarAttributeType.S)) .withProvisionedThroughput(new ProvisionedThroughput() .withReadCapacityUnits(100L) .withWriteCapacityUnits(100L));
  • 54. Players user_id = mza location = Cambridge joined = 2011-07-04 user_id = jeffbarr location = Seattle joined = 2012-01-20 user_id = werner location = Worldwide joined = 2011-05-15 Leader boards Scores user_id = mza game = angry-birds score = 11,000 game = angry-birds score = 11,000 user_id = mza user_id = mza game = tetris score = 1,223,000 game = tetris score = 1,223,000 user_id = mza user_id = werner game = bejewelled score = 55,000 game = tetris score = 9,000,000 user_id = jeffbarr
  • 55. CreateTableRequest createLeaderBoardsTable = new CreateTableRequest().withTableName(”LeaderBoards") .withKeySchema(new KeySchemaElement().withAttributeName(”game") .withKeyType(KeyType.HASH)) .withAttributeDefinitions(newAttributeDefinition() .withAttributeName(”game").withAttributeType(ScalarAttributeType.S)) .withKeySchema(new KeySchemaElement().withAttributeName(”score") .withKeyType(KeyType.RANGE)) .withAttributeDefinitions(newAttributeDefinition() .withAttributeName(”score").withAttributeType(ScalarAttributeType.N)) .withProvisionedThroughput(new ProvisionedThroughput() .withReadCapacityUnits(50L) .withWriteCapacityUnits(50L));
  • 56. Players user_id = mza location = Cambridge joined = 2011-07-04 user_id = jeffbarr location = Seattle joined = 2012-01-20 user_id = werner location = Worldwide joined = 2011-05-15 Query for user Leader boards Scores user_id = mza game = angry-birds score = 11,000 game = angry-birds score = 11,000 user_id = mza user_id = mza game = tetris score = 1,223,000 game = tetris score = 1,223,000 user_id = mza user_id = werner game = bejewelled score = 55,000 game = tetris score = 9,000,000 user_id = jeffbarr
  • 57. Map<String, Condition> keyConditions = new HashMap<String, Condition>(); keyConditions.put("user_id", new Condition() .withComparisonOperator(ComparisonOperator.EQ.toString()) .withAttributeValueList(new AttributeValue().withS("mza"))); QueryRequest queryRequest = new QueryRequest() .withTableName("Players") .withKeyConditions(keyConditions); QueryResult result = dynamoDB.query(queryRequest); for (Map<String, AttributeValue> item : result.getItems()) { printItem(item); }
  • 58. Players user_id = mza location = Cambridge joined = 2011-07-04 user_id = jeffbarr location = Seattle joined = 2012-01-20 user_id = werner location = Worldwide joined = 2011-05-15 Query for scores by user Leader boards Scores user_id = mza game = angry-birds score = 11,000 game = angry-birds score = 11,000 user_id = mza user_id = mza game = tetris score = 1,223,000 game = tetris score = 1,223,000 user_id = mza user_id = werner game = bejewelled score = 55,000 game = tetris score = 9,000,000 user_id = jeffbarr
  • 59. Map<String, Condition> keyConditions = new HashMap<String, Condition>(); keyConditions.put("user_id", new Condition() .withComparisonOperator(ComparisonOperator.EQ.toString()) .withAttributeValueList(new AttributeValue().withS("mza"))); QueryRequest queryRequest = new QueryRequest() .withTableName(”Scores") .withAttributesToGet(”score”, “game”) .withKeyConditions(keyConditions); QueryResult result = dynamoDB.query(queryRequest); for (Map<String, AttributeValue> item : result.getItems()) { printItem(item); }
  • 60. Players user_id = mza location = Cambridge joined = 2011-07-04 user_id = jeffbarr location = Seattle joined = 2012-01-20 user_id = werner location = Worldwide joined = 2011-05-15 Query for scores by user, game Leader boards Scores user_id = mza game = angry-birds score = 11,000 game = angry-birds score = 11,000 user_id = mza user_id = mza game = tetris score = 1,223,000 game = tetris score = 1,223,000 user_id = mza user_id = werner game = bejewelled score = 55,000 game = tetris score = 9,000,000 user_id = jeffbarr
  • 61. Map<String, Condition> keyConditions = new HashMap<String, Condition>(); keyConditions.put("user_id", new Condition() .withComparisonOperator(ComparisonOperator.EQ.toString()) .withAttributeValueList(new AttributeValue().withS("mza"))); keyConditions.put(”game", new Condition() .withComparisonOperator(ComparisonOperator.EQ.toString()) .withAttributeValueList(new AttributeValue().withS(”tetris"))); QueryRequest queryRequest = new QueryRequest() .withTableName(”Scores") .withKeyConditions(keyConditions); QueryResult result = dynamoDB.query(queryRequest); for (Map<String, AttributeValue> item : result.getItems()) { printItem(item); }
  • 62. Players user_id = mza location = Cambridge joined = 2011-07-04 user_id = jeffbarr location = Seattle joined = 2012-01-20 user_id = werner location = Worldwide joined = 2011-05-15 High scores by game Leader boards Scores user_id = mza game = angry-birds score = 11,000 game = angry-birds score = 11,000 user_id = mza user_id = mza game = tetris score = 1,223,000 game = tetris score = 1,223,000 user_id = mza user_id = werner game = bejewelled score = 55,000 game = tetris score = 9,000,000 user_id = jeffbarr
  • 63. Map<String, Condition> keyConditions = new HashMap<String, Condition>(); keyConditions.put(”game", new Condition() .withComparisonOperator(ComparisonOperator.EQ.toString()) .withAttributeValueList(new AttributeValue().withS(”tetris"))); QueryRequest queryRequest = new QueryRequest() .withTableName(”LeaderBoards") .withKeyConditions(keyConditions) . withScanIndexForward(false); QueryResult result = dynamoDB.query(queryRequest); for (Map<String, AttributeValue> item : result.getItems()) { printItem(item); }
  • 64. Players user_id = mza location = Cambridge joined = 2011-07-04 user_id = jeffbarr location = Seattle joined = 2012-01-20 user_id = werner location = Worldwide joined = 2011-05-15 Insert Players Leader boards Scores user_id = mza game = angry-birds score = 11,000 game = angry-birds score = 11,000 user_id = mza user_id = mza game = tetris score = 1,223,000 game = tetris score = 1,223,000 user_id = mza user_id = werner game = bejewelled score = 55,000 game = tetris score = 9,000,000 user_id = jeffbarr
  • 65. Map<String, AttributeValue> itemPlayer = new HashMap<String, AttributeValue>(); itemPlayer.put("user_id", new AttributeValue("eduardohorai")); itemPlayer.put("location", new AttributeValue("Sao Paulo")); itemPlayer.put("joined", new AttributeValue("27/01/2013")); PutItemRequest putItemRequest = new PutItemRequest("Players", itemPlayer); PutItemResult putItemResult = dynamoDB.putItem(putItemRequest);
  • 66. Players user_id = mza location = Cambridge joined = 2011-07-04 user_id = jeffbarr location = Seattle joined = 2012-01-20 user_id = werner location = Worldwide joined = 2011-05-15 Increase writes/reads on Scores!!!!! Leader boards Scores user_id = mza game = angry-birds score = 11,000 game = angry-birds score = 11,000 user_id = mza user_id = mza game = tetris score = 1,223,000 game = tetris score = 1,223,000 user_id = mza user_id = werner game = bejewelled score = 55,000 game = tetris score = 9,000,000 user_id = jeffbarr
  • 67. UpdateTableRequest updateTableRequest = new UpdateTableRequest() .withTableName("Scores") .withProvisionedThroughput(new ProvisionedThroughput() .withReadCapacityUnits(200L) .withWriteCapacityUnits(200L)); UpdateTableResult result = dynamoDB.updateTable(updateTableRequest);
  • 69. Links §  aws.amazon.com/dynamodb   §  aws.typepad.com/brasil/   §  aws.typepad.com   §  awshub.com.br   §  [email protected]