Section 14: AWS Serverless: DynamoDB Flashcards
How do NoSQL databases scale? (direction)
Horizontally
What replication do you get out of the box with DynamoDB
Replication accross 3 AZ
How much can DynamoDB scale?
It can scale to massive workloads
Millions of requests per seconds
Trillions of rows
TBs of storage
All of it completely automatically
How does DynamoDB enable event driven programming?
By providing DynamoDB streams
Does DynamoDB provide the ability to create โdatabasesโ?
No, only tables (itโs a fully managed service, DynamoDB โisโ the DB)
How many rows can a DynamoDB table have?
Infinite
What must all tables have?
A primary key
What are the two types of primary key?
Simple primary key (partition key only)
Composite primary key (partition key + sort key)
What do each item in a DynamoDB table have?
Primary key
Attributes
What is the maximum size of an item in DynamoDB table?
400 KB
Do all items have to share the same attributes in DynamoDB table?
No, they can all have their own, all attributes are nullable
What data types are supported in DynamoDB tables?
Scalar Types
Document Types
Set Types
What Scalar Types are available?
String Number Binary Boolean Null
What Document Types are available?
List
Map
What is the List type?
Ordered collection of values (Similar to JSON array, values donโt have to be of the same type)
What is the Map type?
Unordered collection of name-value pairs (Similar to JSON object (actually ideal for the purpose of storing JSON objects in DynamoDB))
What Set Types are available?
String Set
Number Set
Binary Set
What is a String Set?
โListโ of strings
What is a Number Set?
โListโ of numbers
What is a Binary Set?
โListโ of binaries
What is the role of the partition key in a DynamoDB table?
It defines the partition where the item is going to get stored
How to make sure that data is highly distributed in a DynamoDB table with a simple primary key?
By having diverse partition keys (primary keys)
How is data grouped when using the composite primary key in a DynamoDB table?
Grouped by partition key
What is another name given to the sort key?
Range key
What must be unique when using the simple primary key in a DynamoDB table?
Partition key
What must be unique when using the composite primary key?
The combination (partition key + range key)
What are the two pricing model of DynamoDB tables?
On-demand capacity
Provisioned capacity
How to get better rates when using provisioned capacity?
By purchasing reserved capacity (Similar to how reserved instances work in EC2)
What are the units used to configure the read and write throughput of provisioned capacity DynamoDB tables?
Read Capacity Units (RCU)
Write Capacity Units (WCU)
What does 1 WCU represent?
One write per second for an item up to 1 KB
What happens if you need to write an item which weights more than 1 KB?
More WCU are consummed
Exercice: We write 10 objects per seconds of 2 KB each, how many WCU do we need?
20 WCU
Exercice: We write 6 objects per second of 4.5 KB each, how many WCU do we need?
30 WCU
Exercice: We write 120 objects per minute of 2 KB each, how many WCU do we need?
4 WCU
What is the difference between strongly consistent reads and eventually consistent reads?
With strongly consistent reads you are sure that even if you read right after a write, you will get the data
With eventually consistent reads, you may not get the data if you read right after a write, but you will eventually get the data (if you request it later enough)
Why do we might not get the data if we do an eventually consistent read just after a write?
If we happen to read from an AZ where our written data has not yet been replicated, we might not find the data
By default, DynamoDB uses eventually consistent reads, how can we โenableโ consistent read?
By setting the ConsistentRead parameter to true in our read request
What does 1 RCU represent?
One strongly consistent read per second, or two eventually consistent reads per second, for an item up to 4 KB in size
If the items read are larger than 4 KB, what will happen?
More RCU will be consummed
Exercice: We do 10 strongly consistent reads per seconds of 4 KB each, how many RCU are consummed?
We need 10 * 4 KB / 4 KB = 10 RCU
Exercice: We do 16 eventually consistent reads per seconds of 12 KB each how many RCU are consummed?
We need (16 / 2) * ( 12 / 4 ) = 24 RCU
Exercice: We do 10 strongly consistent reads per seconds of 6 KB each how many RCU are consummed?
We need 10 * 8 KB / 4 = 20 RCU (we have to round up 6 KB to 8 KB)
What does DynamoDB divide data into?
Partitions
How to compute the number of partions used by a DynamoDB table?
Capacity = (TOTAL RCU / 3000) + (TOTAL WCU / 1000)
Size = Total Size / 10 GB
Total partitions = CEILING(MAX(Capacity, Size))
How are WCU and RCU spread accross partitions?
Evenly