More Related Content Similar to Dynamodb presentation (7) Dynamodb presentation1. DYNAMODB DEEP DIVE AND BEST PRACTICES
PRESENTED BY CATHY HUI
DYNAMODB DEEP DIVE AND BEST PRACTICES
PRESENTED BY CATHY HUI
7. class student signupDate SpecialRequest member
Judo Amy_0001 2016-04-01 Personal_trainer 1
Judo John_0002 2016-04-03 0
Karate Amy_0001 2016-03-03 Personal_trainer 1
Karate Bob_0003 2016-05-17 1
Painting
Swimming
Hash Key Range / Sort Key
Items
Attributes
QUERY WHERE HASH KEY = JUDO --- RETURN RESULT SET STUDENT ARE SORTED IN ORDER
8. LOCAL SECONDARY INDEX (LSI)LOCAL SECONDARY INDEX (LSI)
Hash key = table hash key
Diff range key
DEPT
(hash)
EMP
(range)
MGR HIREDATE SALTABLE
DEPT
(hash)
SAL
(range)
EMP
(table key)
KEYS_ONLY
DEPT
(hash)
MGR
(range)
EMP
(table key)
HIREDATE
(projected)
INCLUDE HIREDATE
DEPT
(hash)
HIREDATE
(range)
EMP
(table key)
MGR
(projected)
SAL
(projected)
ALL
LSIs
LIMIT 10GB /PARTITION
9. GLOBAL SECONDARY INDEX (GSI)GLOBAL SECONDARY INDEX (GSI)
Alternate hash key + Optional Range Key
TABLE
HIREDATE
(hash)
DEPT
(table key)
EMP
(table key)
EMP
(hash)
HIREDATE
(hash)
DEPT
(table key)
MGR
(projected)
KEYS_ONLY
INCLUDE MGR
MGR
(hash)
EMP
(range)
DEPT
(table key)
HIREDATE
(projected)
SAL
(projected)
ALL
GSIs
DEPT
(hash)
EMP
(Range)
MGR HIREDATE SAL
10. dept staff contractAgent hireDate title
acct Amy_0001 abc 2015-12-30 accountant
acct Bob_0003 2016-05-05 acct_mgr
acct John_0004 xyz 2016-03-07 accountant
Finance Sydney_0002 2016-05-05 CFO
Engineering Larry_0007 xyz 2016-06-01 developer
Anonymous_0000
Dept_Staff Table
contractAgent staff Dept
xyz John_0004 acct
xyz Larry_0008 Engineering
abc Amy_0001 acct
Hash key Agent GSI
Hash key
Range key
Range key
14. EXAMPLE:
TABLE: AVG ITEM SIZE 12KB
12KB / 4KB = 3 RCUS ß 3 RCUS TO READ 1 ITEM PER SECOND
PREDICT 100 ITEM READS / SEC
100 X 3 RCUS = 300 RCUS (IF EVENTUAL CONSISTENCY READ: 150 RCU)
EXAMPLE:
TABLE: AVG ITEM SIZE 12KB
12KB / 4KB = 3 RCUS ß 3 RCUS TO READ 1 ITEM PER SECOND
PREDICT 100 ITEM READS / SEC
100 X 3 RCUS = 300 RCUS (IF EVENTUAL CONSISTENCY READ: 150 RCU)
15. Expected Item Size Consistency Desired Item Reads
Per Second
Provisioned
ThroughputRequired
4 KB Strongly consistent 50 50
8 KB Strongly consistent 50 100
4 KB Eventually consistent 50 25
8 KB Eventually consistent 50 50
Expected Item Size Desired Item Writes Per
Second
Provisioned Throughput
Required
1 KB 50 50
2 KB 50 100
RCU EXAMPLES:
WCU EXAMPLES:
34. USE OF SPARSE GSI …USE OF SPARSE GSI …
WHEN GSI IS ON A SELECTIVE ATTRIBUTEWHEN GSI IS ON A SELECTIVE ATTRIBUTE
38. ØØ
WORKAROUND: Use of iterator on the application.
Iterator<MyObject> iterator = mapper.query(query.withLimit(20)).iterator();
for (int i = 0; iterator.hasNext() && i < 20; ++i) {
MyObject object = iterator.next();
...
}