22. DynamoDB **IMPORTANT** Flashcards
What is the maximum size of an item in DynamoDB?
400 KB
What are the DynamoDB Primary Key options?
- Simple Primary Key (Partition key only / HASH)
- Composite Primary Key (Partition key + Sort key – combination must be unique)
If we write 6 objects per second of 4.5 KB each, how many WCUs are required?
6 * 5 = 30 WCU
4.5 KB was rounded to nearest KB (5 KB)
If we have 10 strongly consistent reads per second of 6 KB each, how many RCUs are required?
10 * (8 / 4) = 20 RCU
6 KB was rounded to nearest multiple of 4 (8 KB)
If we have 16 eventually consistent reads per second of 12 KB each, how many RCUs are required?
(16 / 2) * (12 / 4) = 8 * 3 = 24 RCU
How are WCU and RCU spread between partitions?
Evenly
WCU and RCU are spread evenly between partitions
ex: 10 partitions w/100 WCU & RCU –> each partition gets 10 WCU & 10 RCU
When can SLI be defined?
Local Secondary Index (LSI) must be defined at table creation time.
When should you use a Global Secondary Index (GSI)?
When you want to speed up queries on non-key attributes
What are the BatchWriteItem limits?
- up to 25 PutItem and/or DeleteItem in one call
- up to 16 MB of data written
- up to 400 KB of data per item
What are the BatchGetItem limits?
- up to 100 items
- up to 16 MB of data
What type of locking does DynamoDB institute?
DynamoDB is an optimist locking / concurrency database
What is DAX?
A seamless cache for DynamoDB (no application re-write required)
What are the DynamoDB stream types?
- KEYS_ONLY
- NEW_IMAGE
- OLD_IMAGE
- NEW_AND_OLD_IMAGES
True or False: Lambda functions are invoked synchronously from DynamoDB Streams.
True.
Lambda functions are invoked synchronously from DynamoDB Streams.
What DynamoDB API options use NextToken?
- -max-items
- -starting-token
What is a transaction?
A transaction is a write to both tables or none.
What Write Sharding solution?
Add a suffix to the partition key (usually a random suffix, sometimes calculated)
What are the DynamoDB write types?
- Concurrent writes
- Atomic writes
- Conditional writes
- Batch writes
What are concurrent writes?
Update itemA value = 1
Update itemA value = 2
The second write overwrites the first write
What are atomic writes?
Update itemA value INCREASE BY 1
Update itemA value INCREASE BY 2
Both writes succeed. The value is increased by 3
What are conditional writes?
Update itemA value = 1 IF value = 0
Update itemA value = 2 IF value = 0
The first write is accepted and the second write fails
What are batch writes?
Write / update many items at a time
How do you store large objects in AWS using DynamoDB?
Store object in S3 and store metadata (including S3 location) from object in DynamoDB
A Sort Key is also known as what?
RANGE
A Partition Key is also known as what?
HASH
What is an LSI?
Local Secondary Index
- Supports strongly or eventually consistent reads
- Can only be created with initial table (cannot be modified and cannot be deleted unless also deleting the table)
- Only Composite
- 10GB or less per partition
- Share capacity units with base table
- Must share Partition Key (PK) with base table
What is a GSI?
Global Secondary Index
- cannot provide strong consistency
- Only eventual consistency reads
- Can create, modify, or delete at anytime
- Simple and Composite
- Can have whatever attributes as Partition - Key (PK) or Sort Key (SK)
- No size restriction per partition
- Has its own capacity settings
What should you use to limit the number of items returned from a query?
ProjectExpression
What can you use to speed up a scan?
Parallel scans using Segments and Total Segments
When shouldn’t you use DAX?
DAX is not ideal for:
- Apps that require strongly consistent reads
- Apps that do not require microsecond read response times
- Apps that are write intensive or that do not perform much read activity
- If you don’t need DAX, consider ElastiCache