DynamoDB Flashcards

1
Q

What is DynamoDB?

A

is a key-value and document database (NoSQL) that delivers single-digit millisecond performance at any scale. It’s a fully managed, multiregion, multimaster, durable database with built-in security, backup and restore, and in-memory caching for internet-scale applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What uses DynamoDB for security administration and auth?

A

IAM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Is DynamoDB replicated?

A

across 3 AZs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are DynamoDB features?

A
  • Scales to massive workloads, distributed database
  • Millions of requests per seconds, trillions of row, 100s of TB of storage
  • Fast and consistent in performance (low latency on retrieval)
  • Enables event driven programming with DynamoDB Streams
  • Low cost and auto scaling capabilities
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is made off DynamoDB?

A

tables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is better to use DynamoDB? read or write?

A

to write: RCU cost = 5 x WCU cost

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What must have DynamoDB provisioned mode tables defined for throughput?

A

Read Capacity Units (RCU) and Write Capacity Units (WCU)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a DynamoDB Read Capacity Unit?

A
  • 1 RCU = 1 strongly consistent read of 4 KB per second

* 1 RCU = 2 eventually consistent read of 4 KB per second

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a DynamoDB Write Capacity Unit?

A

• 1 WCU = 1 write of 1 KB per second

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What you need to have if DynamoDB throughput must be temporarily exceeded?

A

burst credit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What happens If your DynamoDB burst credit is empty

A

you’ll get a “ProvisionedThroughputException”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Can you set auto scaling DynamoDB RCU and WCU

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the read/write capacity modes of DynamoDB?

A

Provisioned (Free tier)

On demand

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is DynamoDB Streams?

A

To capture and process changes to DynamoDB items on a table (Create, Update, Delete) on Streams

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What can read DynamoDB Streams?

A

Lambda

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are good scenarios for using DynamoDB Streams?

A
• React to changes in real time (welcome email to new
users)
• Analytics
• Create derivative tables / views
• Insert into ElasticSearch
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What can you use to implement CRR on DynamoDB?

A

DynamoDB Streams

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the retention time for data on DynamoDB Streams?

A

1 day

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Does DynamoDB accept Transactions?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Can you access DynamoDB without internet?

A

Yes, through VPC endpoints

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Can you encrypt data in DynamoDB?

A

yes, at rest (KMS) and in transit (SSL / TLS)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Can you restore tables using DynamoDB?

A

yes, it has Point In Time Restore and it does not affect performance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is Amazon DMS?

A

AWS Database Migration Service (AWS DMS) is a cloud service that makes it easy to migrate relational databases, data warehouses, NoSQL databases, and other types of data stores

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is DynamoDB Global Tables?

A

provide a fully managed solution for deploying a multiregion (CRR), multi-master database, without having to build and maintain your own replication solution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What you must enable to DynamoDB Global Tables to work?

A

DynamoDB Streams

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

How can you build applications that react to data modifications in DynamoDB tables?

A

Amazon DynamoDB is integrated with AWS Lambda so that you can create triggers—pieces of code that automatically respond to events in DynamoDB Streams.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What is a NoSQL database?

A

NoSQL databases are non-relational, distributed databases that scale horizontally

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is composed of DynamoDB tables?

A
  • Each table has a primary key (must be decided at creation time)
  • Each table can have an infinite number of rows
  • Each row has attributes (can be added over time – can be null)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is DynamoDB item max size?

A

The maximum size of an item is 400KB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What are two options to define a DynamoDB primary key?

A
  • Option 1: Partition key only (HASH)

* Option 2: Partition key + Sort Key (optional)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What conditions must be accomplished by a DynamoDB Partition Key only primary key?

A

o Partition key must be unique for each item
o Partition key must be “diverse” so that the data is distributed
o Example: user_id for a users table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What conditions must be accomplished by a DynamoDB Partition Key + Sort Key primary key?

A
o	The combination must be unique
o	Data is grouped by partition key
o	Sort key is also known as range key
o	Example: users-games table
	user_id for the partition key
	game_id for the sort key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

What is advised to do if you get a DynamoDB ProvisionedThroughputExceptions?

A

o Exponential back-off when exception is encountered (already in SDK)
o Distribute partition keys as much as possible
o If RCU issue, we can use DynamoDB Accelerator (DAX)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

Solve these DynamoDB WCU examples:
• Example 1: we write 10 objects per seconds of 2 KB each.
• Example 2: we write 6 objects per second of 4.5 KB each
• Example 3: we write 120 objects per minute of 2 KB each

A

o We need 2 * 10 = 20 WCU
o We need 6 * 5 = 30 WCU (4.5 gets rounded to the upper KB)
o We need 120 / 60 * 2 = 4 WCU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

What is DynamoDB Eventually Consistent Reads?

A

If we read just after a write, it’s possible we’ll get unexpected response because of replication

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

What is DynamoDB Strongly Consistent Reads?

A

If we read just after a write, we will get the correct data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

What Consistent Read option is used by default on DynamoDB?

A

By default DynamoDB uses Eventually Consistent Reads, but GetItem, Query & Scan provide a “ConsistentRead” parameter you can set to True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

Solve these DynamoDB RCU examples:
• Example 1: 10 strongly consistent reads per seconds of 4 KB each
• Example 2: 16 eventually consistent reads per seconds of 12 KB each
• Example 3: 10 strongly consistent reads per seconds of 6 KB each

A

o We need 10 * 4 KB / 4 KB = 10 RCU
o We need (16 / 2) * ( 12 / 4 ) = 24 RCU
o We need 10 * 8 KB / 4 = 20 RCU (we have to round up 6 KB to 8 KB)

39
Q

How are DynamoDB WCU and RCU spread?

A

WCU and RCU are spread evenly between partitions (if you have 100 WCU and 10 partitions, you will end having 10 WCU per partition)

40
Q

How is data allocated in DynamoDB?

A

Data is divided in partitions. Partition keys go through a hashing algorithm to know to which partition they go to

41
Q

What are 3 reasons to get DynamoDB ProvisionedThroughputExceededExceptions?

A
  • Hot keys: one partition key is being read too many times (popular item for ex)
  • Hot partitions:
  • Very large items: remember RCU and WCU depends on size of items
42
Q

What is DynamoDB PutItem API?

A

Write data to DynamoDB (create data or full replace)

o Consumes WCU

43
Q

What is DynamoDB UpdateItem API?

A

Update data in DynamoDB (partial update of attributes)
o Does not consume WCU
o Possibility to use Atomic Counters and increase them

44
Q

What are DynamoDB Conditionals Writes?

A

o Accept a write / update / delete only if conditions are respected, otherwise reject

45
Q

What is the impact of DynamoDB Conditional Writes in performance?

A

no impact

46
Q

What helps with DynamoDB Conditional Writes?

A

Helps with concurrent access to items

47
Q

What is DynamoDB DeleteItem API?

A

Delete an individual row

48
Q

What is DynamoDB DeleteTable API?

A

o Delete a whole table and all its items

o Much quicker deletion than calling DeleteItem on all items

49
Q

What are DynamoDB BatchWriteItem API limits?

A

o Up to 25 PutItem and / or DeleteItem in one call
o Up to 16 MB of data written
o Up to 400 KB of data per item

50
Q

How does improve performance DynamoDB BatchWriteAPI?

A
  • Batching allows you to save in latency by reducing the number of API calls done against DynamoDB
  • Operations are done in parallel for better efficiency
51
Q

What is DynamoDB GetItem API?

A

o Read based on Primary key

o Primary Key = HASH or HASH-RANGE

52
Q

What are DynamoDB BatchGetItem API limits?

A

o Up to 100 items
o Up to 16 MB of data
o Items are retrieved in parallel to minimize latency

53
Q

What is DynamoDB Query API?

A
returns items based on:
o	PartitionKey
o	SortKey value
o	FilterExpression
Able to do pagination on the results
54
Q

What particularity is there about a DynamoDB partition key used in a Query API call?

A

it must use = operator

55
Q

What particularity is there about a DynamoDB sort key used in a Query API call?

A

can use several optional operands (=, , >=, Between, Begin)

56
Q

How much data can you get by using DynamoDB Query API call?

A

o Up to 1 MB of data

o Or number of items specified in Limit

57
Q

What can you query on DynamoDB by using Query API?

A

Can query table, a local secondary index, or a global secondary index

58
Q

What is DynamoDB Scan API?

A

Scan the entire table and then filter out data consumes a lot of RCU (inefficient)

59
Q

How much data can you get by using DynamoDB Scan API call?

A

Returns up to 1 MB of data – use pagination to keep on reading

60
Q

What is DynamoDB LSI?

A

Local Secondary Index is an alternate sort key for your table, local to the hash key

61
Q

How many DynamoDB LSI can you define?

A

Up to five local secondary indexes per table.

62
Q

What regulations does have DynamoDB LSI?

A
  • The attribute that you choose must be a scalar String, Number, or Binary
  • LSI must be defined at table creation time
63
Q

What is DynamoDB GSI?

A

To speed up queries on non-key attributes, use a Global Secondary Index
• GSI = partition key + optional sort key

64
Q

What represents a DynamoDB GSI?

A

The index is a new “table” and we can project attributes on it
o The partition key and sort key of the original table are always projected (KEYS_ONLY)
o Can specify extra attributes to project (INCLUDE)
o Can use all attributes from main table (ALL)

65
Q

What you must define for DynamoDB GSI indexes?

A

Must define RCU / WCU for the index

66
Q

What possibility is provided for DynamoDB GSI that is not for LSI?

A

Possibility to add / modify GSI (not LSI)

67
Q

What is DynamoDB in terms of concurrency?

A

An optimistic locking / concurrency database. That means that you can ensure an item hasn’t changed before altering it

68
Q

What code changes do you need to do to use DynamoDB DAX?

A

no application re-write

69
Q

What happens to writes and reads in DynamoDB DAX?

A
  • Writes go through DAX to DynamoDB

* Micro second latency for cached reads & queries

70
Q

What is the TTL cache value by default for DynamoDB DAX?

A

5 minutes

71
Q

How many nodes can you set when using DynamoDB DAX?

A

Up to 10, 3 recommendend for Multi-AZ

72
Q

What is a good case scenario to integrate DynamoDB DAX + ElastiCache?

A
  • DAX stores Individual Objects, Query, Scan cache

- ElastiCache stores Aggregation Results

73
Q

What can be used for DynamoDB streams?

A
o	React to changes in real time (welcome email to new users)
o	Analytics
o	Create derivative tables / views
o	Insert into ElasticSearch
o	CRR
74
Q

What is the data retention period for DynamoDB streams?

A

1 day

75
Q

What options do you have in terms of what data is written to a DynamoDB stream?

A

o KEYS_ONLY — Only the key attributes of the modified item.
o NEW_IMAGE —The entire item, as it appears after it was modified.
o OLD_IMAGE —The entire item, as it appeared before it was modified.
o NEW_AND_OLD_IMAGES — Both the new and the old images of the item.

76
Q

What is made of DynamoDB streams?

A

of shards like Kinesis, but you don’t provission shards as you do in Kinesis

77
Q

What records end up in a DynamoDB stream?

A

New changes. Records are not retroactively populated in a stream after enabling it

78
Q

How much WCU and RCU uses deletions in DynamoDB

A

deletions do not use it

79
Q

What is DynamoDB TTL?

A

A background task operated by DynamoDB that automatically deletes an item after an expiry date / time

80
Q

What is DynamoDB TTL applied to?

A

TTL is enabled per row (you define a TTL column, and add a timestamp)
Deleted items due to TTL are also deleted in GSI / LSI

81
Q

When does DynamoDB delete an expired record due to the TTL?

A

DynamoDB typically deletes expired items within 48 hours of expiration

82
Q

What can help recover expired items due to DynamoDB TTL?

A

DynamoDB streams

83
Q

What is –projection-expression CLI option used for in DynamoDB?

A

you specify attributes to get from the table:

–projection-expression “user_id, user_name”

84
Q

What is –filter-expression CLI option used for in DynamoDB?

A

you can filter the rows to get from the table:

–filter-expression “user_id = :u” –expression-attribute-values ‘{ “:u”: {“S”:”userID123”}}’

85
Q

What is –page-size CLI option used for in DynamoDB?

A

you get all data but behind scenes API CALLS = TOTAL_ROWS / PAGE_SIZE are executed. This is hepful to avoid timeouts:
–page-size 1

86
Q

What is –max-items CLI option used for in DynamoDB?

A

you get just the amount of data specified in MAX_ITEMS but behind scenes just 1 API CALL is executed, you can use the NEXT_TOKEN to continue retrieving data. Useful for pagination:
–max-items 5

87
Q

What is –starting-token CLI option used for in DynamoDB?

A

used in conjunction with max-items to keep on reading new max_items rows, no new API calls. Useful for pagination:
–starting-token wNDWJ4rem3FUNWwefewmf2

88
Q

What new Write and Read mode was added to DynamoDB on 2018?

A

Transactional mode

89
Q

How much WCU and RCU is consumed by DynamoDB Transactional mode?

A

2x

90
Q

What is DynamoDB Write Sharding concept?

A

• Imagine we have a voting application with two candidates, candidate A and candidate B.
• If we use a partition key of candidate_id, we will run into partitions issues, as we only have two partitions
• Solution: add a suffix (usually random suffix, sometimes calculated suffix)
Candidate_A-1
Candidate_A-1
Candidate_A-2
Candidate_B-1

91
Q

What is DynamoDB Conditional Write?

A

If you have concurrent operations they should use a conditional value in the query; that guarantees the first operation is accepted and the second fails

92
Q

What is DynamoDB Atomic Write?

A

If you have concurrent operations increasing same item value both writes will succeed and the item value will be increased twice

93
Q

What pattern can you use in DynamoDB to store large objects?

A

Send object to S3 and store small metadata in DynamoDB