Section 8 - DynamoDB Flashcards

1
Q

List 6 different types of databases supported by the AWS ecosystem?

A
  • RDS
  • Aurora
  • DynamoDB
  • DocumentDB
  • ElastiCache
  • Neptune
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Amazon DynamoDB?

A

DynamoDB is a fully managed NoSQL key-value and document database.

  • NoSQL key-value database
  • Fully managed and serverless
  • Non-relational
  • Scales automatically to massive workloads with fast performance
  • performance
    • SSD Storage
  • Resilience
    • Spread across 3 geographically distinct data centers
  • Consitency
    • Eventually consistent reads (default)
    • Strong consistent reads
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

AWS DynamoDB Constistency Models?

A
  • Eventually consistent reads (default)
    • Consistency across all copies of data is usually reached within a second.
    • Best for read performance
  • Strong consistent reads
    • A stronly consistent read always reflects all successful writes.
    • Writes are reflected across all 3 locations at once.
    • Best for read consistency
  • ACID Transactions
    • ​DynamoDB transations provide the ability to perform ACID Transactions (Atomic, Constistent, Isolated, Durable)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

AWS DynamoDB Primary Keys?

A

DynamoDb stores and retrieves data based on a primary key.

Two types of primary keys:

  • Partition Key
    • A unique attribute
    • 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.
    • e.g. Customer_ID=7886544, product_id,email address ..
  • Composite key (partition key + sort key)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

AWS DynamoDB Access Control?

A
  • Fine-Grained Access Control with IAM
  • IAM condition paramter
    • dynamodb:LeadingKeys allows users to access only the items where the partition key value matches their User_ID
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

AWS DynamoDB indexes?

A

Query based on an attribute that is not the primary key.

  • DynamoDB allows you to run a query on non-primary key attributes using global secondary indexes and local secondary indexes.
  • A secondary index allow you to perform fast queries on specific columns in a table. You select the columns that you want included in the index and run your searches on the index, rather than on entire dataset.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

AWS DynamoDB Local Secondary Index?

A
  • Primary Key
    • Same partition key as your original table but a different sort key
  • A Different View
    • Gives you a different view of your data, organized according to an alternative sort key
  • Faster Queries
    • Any queries based on this sort key are much faster using the index than the main table.
  • An Example
    • Partition Key: User ID
    • sort Key: account creation date
  • Add at Creation Time
    • Can only be created when you are creating your table. You cannot add remove or modify it later.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

AWS DynamoDB Global Secondary Index?

A
  • A Completely Different Primary key
    • Different partition key and sort key
  • View Your Data Differently
    • Gives a completely different view of the data.
  • Speeds Up Queries
    • Speeds up any queries relating to this alternative partition and sort key.
  • An Example
    • Partition Key: email address
    • Sort key: last log in date
  • Flexible
    • You can create when you create your table or add it later.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

AWS DynamoDB Query?

A
  • Sort key
    • Results are always sorted by the sort key
  • Numeric Order
    • In ascending numeric order by default (e.g. 1,2,3,4)
  • ASCII
    • ASCII character code values
  • Reverse The Order
    • You can reverse the order by setting the ScanIndexForward parameter false.
  • Eventually Consistent
    • By default, queries are eventually consistent.
  • Strongly Consitent
    • You need to explicitly set the query to be strong consistent.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

AWS DynamoDB Scan Vs Query?

A
  • Query is More efficient than a scan
    • A scan dumps the entire table and filters out the values to provide the desired result, removing the unwanted data
  • Extra Step
    • Adds extra step of removing the data you don’t want
    • As the table grows, the scan operation takes longer
  • Provisioned Throughput
    • A scan operation on a large table can use up the provisision throughput for large table in just a single operation.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

AWS DynamoDB Imporving Query and Scan perfomance?

A
  • Set a smaller page size
    • e.g. set the page size to return 40 items
  • Avoid scans
    • Avoid using scans operations if you can. Design tables in a way that you can use the Query, Get, or BatchGetItem APIs
  • Paralle Scans
    • You can configure DynamoDB to use parallel scans instead by logically deviding a table or index into segments and scanning each segment in parallel
    • Beware: it’s best to aoid parallel scans if your table or index is already incurring heavy read or write activity from another applications.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

AWS DynamoDB Provisioned Throughput?

A

Measured in Capacity Units:

  • When you create your table, you can specify your requirements in terms of read capacity units and write capacity units
  • Write Capacity Units
    • 1 X Write capacity unit = 1 x 1KB write per second
  • Read Capacity Units
    • 1 X Read capacity unit = 1 x Strongly Consistent read of 4kb per second.
    • OR 2 X Eventually Consistent reads of 4KB per second (default)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

AWS DynamoDB On-Demand Capacity?

A
  • DynamoDb Instantly scales up and down based on your activity of your application.
  • Charges apply for reading and writing, and storing data.
  • Ideal for :
    • Unpredictable workloads
    • New applications where you don’t know the use pattern
    • When you want to pay for only what you use (pay per request)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

AWS DynamoDB Which pricing model to use?

A

On-Demand Capacity:

  • Unknown workloads
  • Unpredictable application traffic
  • Spiky,short-lived peaks.
  • A pay-per-use model is desired
  • It might be more difficult to predict the cost.

Provision Capacity

  • Read and write capacity requirements can be forecasted
  • Predictable application traffic
  • Application traffic is consistent or increases gradually
  • You have more control over the cost.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

AWS DynamoDB Accelerator (DAX)?

A
  • DynamoDB Accelerator (Or DAX) is a fully managed, clustered in-memory cache for DynamoDB
  • Delivers up to a 10x read performance improvement. Microsecond performance for millions of requests per second.
  • DAX is a write-through caching service. Data is written to the cache and the backend store at the same time.
  • DynamoDB API calls are pointed to DAX (cache), and if an item is not found then DAX gets the item from the DynamoDB, caches it and send it back to the API call.
  • Caters for eventually consistent reads only.
  • No suitable for:
    • Applications which are mainly write intensive
    • Applications that do not perform many read operations
  • Ideal for:
    • Read-heavy workloads and bursty wordloads
    • e.g. Auction applications,Gaming site, Ecommerce (Black Friday sale)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

AWS DynamoDB TTL?

A

Time To Live (TTL)

  • Defines an expiry time for your data.
  • Expired items marked for deletion.
  • Once an item is marked for deletion, it’s removed after 48 hrs.
  • Great for removing irrelevant or old data, (e.g. Session data, Event logs, and temporary data)
17
Q

AWS DynamoDB Streams?

A
  • Time ordered sequence
    • Time-ordered sequence of item level modifications (e.g. Insert, update, delete)
  • Logs
    • Encrypted at rest and stored for 24 hrs
  • Dedicated Endpoint
    • Accessed using a dedicated end point
  • Primary key
    • By default, the primary key is recorded
  • Images
    • Before and fater images can be captured
  • Use Cases
    • Audit or archive transactions; trigger an event based on a particular transaction; or replicate data across multiple tables
    • data replication across multiple DynamoDB instances
18
Q

AWS DynamoDB Provisioned Throughput Exceeded?

A
  • ProvisionThroughputExceededException
    • Your request rate is too high for the read/ write capacity provisioned on your DynamoDB table.
  • Using the AWS SDK?
    • The SDK will automatically retry the requests until successful.
  • Not using the AWS SDK?
    • Reduce your request frequency. use exponential backoff.
19
Q

What is Exponential Backoff?

A

Overloaded components:

In addition to simple retries, all AWS SDKs use exponential backoff.

Exponential Backoff: Uses progressively longer waits between consecutive retries, for improved flow control.

20
Q
A