DynamoDB Flashcards
What is DynamoDB
A fast and flexible NoSQL database. Serverless. Items stored on SSD storage.
Data models that DynamoDB supports
Document (JSON, HTML, or XML)
Key_value pairs
How many geographic distinct data centers is DynamoDB spread across
3
Default consistency model of Dynamo DB
Eventually Consistent Reads
2 types of primary keys DynamoDB supports
Partition Key - unique attribute
Composite Key- combo of partition key and sort key
IAM Condition you can set to restrict user access to their own records in DynamoDB
dynamodb:LeadingKeys
What is an index in DynamoDB
Way to perform fast queries on colum in table can select column you want to include
Local Secondary Index
Must be created when create table
Can not be removed or modified after creation
Partition key must be same as original table
Queries are much faster in index than main table
Global Secondary Index
Can create after table is created
Can edit or delete
Can have different partition key
What can you use if you want a query to only return specific attributes DynamoDB?
ProjectionExpression
How are results sorted DynamoDB?
Ascending order
can reverse by setting ScanIndexForward to false
How to improve performance of a scan
Reduce page size
Avoid using scan if you can
Use parallel scan but try to avoid if table or index is already incurring heavy read and write activity
1 X Write Capacity Unit
1 x Write of 1 KB/sec
1 x Read Capacity Uni
1 x Strongly Consistent Read of 4KB/sec
1 x Read Capacity Unit
2 x Eventually Consistent Read of 4KB/sec
DynamoDB Capacity options (2)
On-Demand
Provisioned
When to use Provisioned Capacity DynamoDB
Predicatble app traffic. Traffic is consistent or gradual.
Note you can change provisioned to on-demand once per day.
What to use if you want IOX ready performance improvement for heavy read workloads DynamoDB
DAX (DynamoDB accelerator)
What is DAX?
fully managed in-memory cache for DynamoDB.
Uses Write Through Caching.
Eventually Consistent Reads
What is DAX not suitable for?
Write intensive apps
Want to use Lazy Loading
Strongly Consistent Read apps
Apps that don’t have many reads
How to remove irrelevant or old data in DynamoDB
Set TTL
Once marked for delete it will be deleted after 48hrs
Can filter out expired items for queries and scans
Describe DynamoDB Streams
Time-ordered sequence of item level modifications (insert, update, delete)
Logs are encrypted at rest and stored for 24 hrs
Event source for Lambda (perform action when there is a change to the dynamo table)
Provisioned ThroughputException
Request rate too high for read/write capcity in DynamoTable
SDK auto retries till successful
If not using SDK (reduce request frequency, use exponential backoff)
Exponential Backoff
Progressively longer wait between consecutive retries
50ms, 100ms, 200ms
If that doesn’t work it could be request size is exceeding throughput for read write capacity.