NOSQL Database & DynamoDB Flashcards
DynamoDB
NoSQL Public Database-as-a-service(DBaas)-key/vale & document
Manual/Automatic provisioned performace in/out or on-demand
Really fast .. single-digit milisecond(ssd based)
What is the resiliency of DynamoDB?
highly resilient across AZ and optionally globally
What is the Capacity of a Dynamo Table and it’s units
Capacity is speed
(Writes) 1 WCU = 1KB per second
(Reads) 1 RCU = 4KB per second
DynamoDB Backups
On demand Backups
Point-in-time Recovery(PITR)
DynamoDB billing
billed based RCU ,WCU, storage and features
What the one Requirement for data entering DynamoDB ?
Has to have a unique simple(partition) or Composite (partition & Sort) Primary Key
Each item must have a unique value for PK and SK, Can have none ,all ,mixture or different attributes (DDB has no ridged attributes schema)
DynamoDB Query
Query accepts a single PK value and optionally a SK or range .Capacity consumed is the size of all returned items. Further filtering discards data-capacity is still consumed. Can Only query on PK or PK and SK.
Always beneficial to return more items because every read consumes as least 1RCU because the value read is always rounded up to 1RCU
DynamoDB capacity modes
on-Demand - you just pay for the operations on the table. unknown unpredictable, low admin.
provisioned - you have to set the capacity values on a per table basis. price per millions R or W units
more expensive - price per millions R or W units
DynamoDB Scan
Scan moves through a table consuming the capacity of every ITEM. You have complete control on what data is selected, any attributes can be used and any filters applied but scan consumes capacity for every item scanned through.
Most flexible but most expensive when it come to capacity
DynamoDB Consistency Model
Eventually consistent reads = check ½ nodes - could be unlucky with stale data if a node is checked before replication completes. 50% of the cost vs. strongly consistent.
Strongly consistent reads = connect to the leader node to get the most up-to-date copy of data
How would you calculate the WCU on your table if you need to store 10 items per second … with 2.5K average size per item?
calculate WCU per items .. round up (item size/1KB)(3)
Multiply by average number per second (30)
= WCU Required (30)
How would you calculate the RCU on your table if you need to store 10 items per second … with 2.5K average size per item? What if the capacity mode was eventually consistent ?
calculate RCU per item… round up (items size/4KB)(1)
Multiply by average read ops per second(10)
= strongly consistent RCU required(10)
DynamoDB Indexes
indexes are alternative views on table data
Different SK(LSI) or Different PK and SK(GSI)
some or all the attributes (projections)
Dynamo DB Local Secondary Indexes(LSI)
LSI is an alternative view for a table
Must be created with a table
5 LSI’s per base table
Shares the TCU and WCU with the table
Attributes - ALL, KEYS_ONLY & INCLUDE
DynamoDB Global Secondary Indexes(GSI)
can be created at any time
Default limit of 20 per base table
Alternative PK and SK
GSI’s have their own RCU and WCU allocations
Draw back of Global Secondary Indexes(GSI)
GSI’s are always eventually consistent, replication between base and GSI is Asynchronous
When would you use GSI vs LSI on a Dynamo table ?
Use GSI’s as default , LSI only when strong consistency is required