Amazon DynamoDB Flashcards
What is Amazon DynamoDB
Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability.
Amazon DynamoDB stores three geographically distributed replicas of each table to enable high availability and data durability.
Data is synchronously replicated across 3 facilities (AZs) in a region.
DynamoDB is a serverless service – there are no instances to provision or manage ?
True
How is Data Stored, Medium ?
Data is stored on SSD storage.
Redundacy Strategy ?
Multi-AZ redundancy and Cross-Region Replication option.
DynamoDB is made up of ?
- Tables.
- Items.
- Attributes.
Tables are a collection of items and items are made up of attributes (columns).
Attributes consists of a name and a value or set of values.
Size Limitations
The aggregate size of an item cannot exceed 400KB including keys and all attributes.
Can store pointers to objects in S3, including items over 400KB.
Documents can be written in ?
Documents can be written in JSON, HTML, or XML.
DynamoDB Features ?
Please see attachment
Anti-Patterns
Amazon DynamoDB is not ideal for the following situations ?
- Traditional RDS apps.
- Joins and/or complex transactions.
- BLOB data.
- Large data with low I/O rate.
Access control Principles
All authentication and access control is managed using IAM.
DynamoDB supports identity-based policies ?
- Attach a permissions policy to a user or a group in your account.
- Attach a permissions policy to a role (grant cross-account permissions).
DynamoDB doesn’t support resource-based policies.
You can use a special IAM condition to restrict user access to only their own records.
These resources and subresources have unique Amazon Resource Names (ARNs) , please specify ?
Tablearn:
aws:dynamodb:region:account-id:table:table/name-name
Indexarn
:aws:dynamodb:region:account-id:table:table/name-name/index/index-name
Streamarn:
aws:dynamodb:region:account-id:table:table/name-name/stream/stream-label
Explain Partitions ?
Amazon DynamoDB stores data in partitions.
A partition is an allocation of storage for a table that is automatically replicated across multiple AZs within an AWS Region.
Partition management is handled entirely by DynamoDB—you never have to manage partitions yourself.
DynamoDB allocates sufficient partitions to your table so that it can handle your provisioned throughput requirements.
DynamoDB allocates additional partitions to a table in the following situations ?
- If you increase the table’s provisioned throughput settings beyond what the existing partitions can support.
- If an existing partition fills to capacity and more storage space is required.
Primary Keys principles ?
DynamoDB stores and retrieves data based on a Primary key.
There are two types of Primary key:
Partition key – unique attribute (e.g. user ID).
- Value of the Partition key is input to an internal hash function which determines the partition or physical location on which the data is stored.
- If you are using the Partition key as your Primary key, then no two items can have the same partition key.
What is Composite Key ?
Composite key – Partition key + Sort key in combination.
- Example is user posting to a forum. Partition key would be the user ID, Sort key would be the timestamp of the post.
- 2 items may have the same Partition key, but they must have a different Sort key.
- All items with the same Partition key are stored together, then sorted according to the Sort key value.
- Allows you to store multiple items with the same partition key.
Partitions and Performance Limitations ?
DynamoDB evenly distributes provisioned throughput—read capacity units (RCUs) and write capacity units (WCUs) among partitions
If your access pattern exceeds 3000 RCU or 1000 WCU for a single partition key value, your requests might be throttled.
Partitions and Performance: Reading or writing above the limit can be caused by these issues ?
- Uneven distribution of data due to the wrong choice of partition key.
- Frequent access of the same key in a partition (the most popular item, also known as a hot key).
- A request rate greater than the provisioned throughput.
Best practices for partition keys ?
Use high-cardinality attributes – e.g. e-mailid, employee_no, customerid, sessionid, orderid, and so on.
Use composite attributes – e.g. customerid+productid+countrycode as the partition key and order_date as the sort key.
Cache popular items – use DynamoDB accelerator (DAX) for caching reads.
Add random numbers or digits from a predetermined range for write-heavy use cases – e.g. add a random suffix to an invoice number such as INV00023-04593
What are the Consistency Models ?
DynamoDB supports eventually consistent and strongly consistent reads.
What is Eventually consistent reads ?
When you read data from a DynamoDB table, the response might not reflect the results of a recently completed write operation.
The response might include some stale data.
If you repeat your read request after a short time, the response should return the latest data.
What is Strongly consistent reads ?
- When you request a strongly consistent read, DynamoDB returns a response with the most up-to-date data, reflecting the updates from all prior write operations that were successful.
- A strongly consistent read might not be available if there is a network delay or outage. In this case, DynamoDB may return a server error (HTTP 500).
- Strongly consistent reads may have higher latency than eventually consistent reads.
- Strongly consistent reads are not supported on global secondary indexes.
- Strongly consistent reads use more throughput capacity than eventually consistent reads.
DynamoDB uses eventually consistent reads by default.
You can configure strongly consistent reads with the GetItem, Query and Scan APIs by setting the –consistent-read (or ConsistentRead) parameter to “true” ? T/F
That is True
DynamoDB Transactions, what is it ?
Amazon DynamoDB transactions simplify the developer experience of making coordinated, all-or-nothing changes to multiple items both within and across tables.
Transactions provide atomicity, consistency, isolation, and durability (ACID) in DynamoDB.
Enables reading and writing of multiple items across multiple tables as an all or nothing operation.
With the transaction write API ?
With the transaction write API, you can group multiple Put, Update, Delete, and ConditionCheck actions.
You can then submit the actions as a single TransactWriteItems operation that either succeeds or fails as a unit.