DynamoDB Flashcards Preview

AWS Developer > DynamoDB > Flashcards

Flashcards in DynamoDB Deck (14)
Loading flashcards...
1

DynamoDB

Amazon DynamoDB is a fast and flexible NoSQL database service for all applications that need consistent, single-digit millisecond latency at any scale. It is a fully managed database and supports both document and key-value data models. Its flexible data model and reliable performance make it a great fit for mobile, web, gaming, ad-tech, IoT, and many other applications.

DynamoDB

Amazon DynamoDB is a fast and flexible NoSQL database service for all applications that need consistent, single-digit millisecond latency at any scale. It is a fully managed database and supports both document and key-value data models. Its flexible data model and reliable performance make it a great fit for mobile, web, gaming, ad-tech, IoT, and many other applications.

2

DynamoDB

  • Stored exclusively on SSD storage to provide high I/O performance
  • Spread across 3 geographically distinct data centres
  • Eventual Consistent Reads (default)
    • Consistency across all copies of data is usually reached within a second. Repeating a read after a short time should return the updated data (Best read performance)
  • Strongly Consistent Reads
    • A strongly consistent read returns a result that reflects all writes that received a successful response prior to the read

DynamoDB

  • Stored on SSD storage
  • Spread across 3 geographically distinct data centres
  • Eventual Consistent Reads (default)
    • Consistency across all copies of data is usually reached within a second. Repeating a read after a short time should return the updated data (Best read performance)
  • Strongly Consistent Reads
    • A strongly consistent read returns a result that reflects all writes that received a successful response prior to the read

3

DynamoDB Basics

  • Tables
  • Items (think of a row of data in a table)
  • Attributes (think of a column of data in a table)

DynamoDB Basics

  • Tables
  • Items (think of a row of data in a table)
  • Attributes (think of a column of data in a table)

4

Primary Keys

Two types of Primary Keys available:

  • Single Attribute (think unique ID)
    • Partition Key (Hash Key) composed of one attribute.
  • Composite (think unique ID and a date range)
    • Partition Key & Sort Key (Hash & Range) composed of two attributes

Primary Keys

Two types of Primary Keys available:

  • Single Attribute (think unique ID)
    • Partition Key (Hash Key) composed of one attribute.
  • Composite (think unique ID and a date range)
    • Partition Key & Sort Key (Hash & Range) composed of two attributes

5

Partition Key

  • DynamoDB uses the partition key's value as input to an internal hash function. The output from the hash function determines the partition (this is simply the physical location in which the data is stored).
  • No two items in a table can have the same partition key value. 

Partition Key

  • DynamoDB uses the partition key's value as input to an internal hash function. The output from the hash function determines the partition (this is simply the physical location in which the data is stored).
  • No two items in a table can have the same partition key value. 

6

Partition Key and Sort Key

  • DynamoDB uses the partition key's value as input to an internal hash function. The output from the hash function determines the partition (this is simply the physical location in which the data is stored).
  • Two items in a table can have the same partition key value, but they must have a different sort key
  • All items with the same partition key are stored together, in sorted order by sort key value

Partition Key and Sort Key

  • DynamoDB uses the partition key's value as input to an internal hash function. The output from the hash function determines the partition (this is simply the physical location in which the data is stored).
  • Two items in a table can have the same partition key value, but they must have a different sort key
  • All items with the same partition key are stored together, in sorted order by sort key value

7

  • Local Secondary Index
    • Has the SAME partition key, different sort key
    • Can ONLY be created when creating a table. They cannot be removed or modified later.
  • Global Secondary Index
    • Has DIFFERENT Partition key and different sort key
    • Can be created at table creation or added LATER

  • Local Secondary Index
    • Has the SAME partition key, different sort key
    • Can ONLY be created when creating a table. They cannot be removed or modified later.
  • Global Secondary Index
    • Has DIFFERENT Partition key and different sort key
    • Can be created at table creation or added LATER

8

Local VS Global Secondary Index

Local VS Global Secondary Index

9

DynamoDB Streams

Used to capture any kind of modification of the DynamoDB tables.

  • If a new item is added to the table, the stream captures an image of the entire item, including all of its attributes.
  • If an item is updated, the stream captures the "before" and "after" image of any attributes that were modified in the item.
  • If an item is deleted from the table, the stream catpures an image of the entire item before it was deleted

DynamoDB Streams

Used to capture any kind of modification of the DynamoDB tables.

  • If a new item is added to the table, the stream captures an image of the entire item, including all of its attributes.
  • If an item is updated, the stream captures the "before" and "after" image of any attributes that were modified in the item.
  • If an item is deleted from the table, the stream catpures an image of the entire item before it was deleted

10

Query and Scans

  • A Query operation finds items in a table using only primary key attribute values. You must provide a partition key attribute name and a distinct value to search for.
  • A Scan operation examines every item in the table. By default, a Scan returns all of the data attributes for every item; however, you can use the ProjectionExpression parameter so that the Scan only returns some of the attributes, rather than all of them.
  • Try to use a Query operation over a Scan operation as it is more efficient.

Query and Scans

  • A Query operation finds items in a table using only primary key attribute values. You must provide a partition key attribute name and a distinct value to search for.
  • A Scan operation examines every item in the table. By default, a Scan returns all of the data attributes for every item; however, you can use the ProjectionExpression parameter so that the Scan only returns some of the attributes, rather than all of them.
  • Try to use a Query operation over a Scan operation as it is more efficient.

11

DynamoDB Throughput 

You have an application that requires to read 5 items of 10 KB per second using eventual consistency. What should you set the read throughput to?

  • First we calculate how many read units per item we need
  • 10 KB rounded up to the nearest increment of 4 KB is 12 KB
  • 12 KB / 4 KB = 3 read units per item
  • 3 x 5 read items = 15
  • Using eventual consistency we get 15/2 = 7.5
  • 8 units of read throughput

DynamoDB Throughput 

You have an application that requires to read 5 items of 10 KB per second using eventual consistency. What should you set the read throughput to?

  • First we calculate how many read units per item we need
  • 10 KB rounded up to the nearest increment of 4 KB is 12 KB
  • 12 KB / 4 KB = 3 read units per item
  • 3 x 5 read items = 15
  • Using eventual consistency we get 15/2 = 7.5
  • 8 units of read throughput

12

Write Throughput

You have an application that requires to write 12 items of 100 KB per item each second. What should you set the write throughput to?

  • Each write unit consist of 1 KB of data. You need to write 12 items per second with each item having 100 KB of data
  • 12 x 100 KB = 1200 write units
  • Write throughput of 1200 Units

Write Throughput

You have an application that requires to write 12 items of 100 KB per item each second. What should you set the write throughput to?

  • Each write unit consist of 1 KB of data. You need to write 12 items per second with each item having 100 KB of data
  • 12 x 100 KB = 1200 write units
  • Write throughput of 1200 Units

13

Error Codes

400 HTTP Status Code - ProvisionedThroughputExceededException

You exceeded your maximum allowed provisioned throughput for a table or for one or more global secondary indexes.

14

Steps taken to authenticate

  • User authenticates with ID provider (such as Facebook)
  • They are passed a Token by their ID provider
  • Your code calls AssumeRoleWithWebIdentity API and provides the providers token and specifies the ARN for the IAM Role
  • App can now access DynamoDB from between 15 minutes to 1 hour (default is 1 hour)

Steps taken to authenticate

  • User authenticates with ID provider (such as Facebook)
  • They are passed a Token by their ID provider
  • Your code calls AssumeRoleWithWebIdentity API and provides the providers token and specifies the ARN for the IAM Role
  • App can now access DynamoDB from between 15 minutes to 1 hour (default is 1 hour)