Basics Flashcards

1
Q

DynamoDB is almost schema-less but you do have to define some aspects of the database before starting. What aspects of a DynamoDB database must be defined (aside from the table name)?

A

Primary Key

Indexes

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

What are the two different kinds of primary keys DynamoDB supports?

A

Partition Key

Partition Key and Sort Key

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

The items in a DynamoDB table may be divided up and spread across multiple partitions.

How does DynamoDB determine which item to put in which partition if the table has a simple primary key?

A

DynamoDB uses the partition key as input to an internal hash function. The output value from the hash function determines the partition in which the item will be stored.

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

The items in a DynamoDB table may be divided up and spread across multiple partitions.

How does DynamoDB determine which item to put in which partition if the table has a composite primary key?

A

DynamoDB calculates the hash value of the partition key.

All items with the same partition key value are stored physically close together.

The order in which they are stored is determined by the Sort Key value.

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

AWS manages partitions for its users based on table size and throughput. What is the formula used by AWS to determine how many partitions to allocate to a table?

A

partitions =

MAX(Table Size / 10GB,
(RCU desired/3000 + WCU desired, 1000))

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

How many write capacity units (WCU) can a single partition support?

A

1000

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

How many GB of data can a single partition handle?

A

10GB

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

When will DynamoDB add another partition to a table?

A

When one or more of the following occurs:

  • more than 10GB of data stored
  • more than 3000 RCUs
  • more than 1000 WCUs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A good partition key will distribute the items evenly across the partitions. What 2 criteria can be used to make this choice?

A

Select an attribute..

  1. with as many distinct values as possible (employee ID better than department ID)
  2. which ensures even access (candidate ID only OK if expect all candidates to receive a similar number of votes and not for 2 to dominate)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can you allocate more partitions to your table?

A

You can’t, you can only estimate and design accordingly. DynamoDB manages table partitioning for its users automatically.

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

How can you allocate more partitions to your table?

A

You can’t, you can only estimate and design accordingly. DynamoDB manages table partitioning for its users automatically.

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

If you want to create a DynamoDB table with 5000 RCUs and 2000 WCUs. How many partitions would be allocated to it and how many RCUs and WCUs would each partition have?

A

( 5,000 / 3,000 ) + ( 2,000 / 1,000 ) = 3.6667 –> 4

5,000 read capacity units / 4 partitions = 1,250 read capacity units per partition

2,000 write capacity units / 4 partitions = 500 write capacity units per partition

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

What is burst capacity?

A

When you are not fully utilizing a partition’s throughput, DynamoDB retains a portion of your unused capacity for later bursts of throughput usage.

DynamoDB currently retains up to five minutes (300 seconds) of unused read and write capacity.

During an occasional burst of read or write activity, these extra capacity units can be consumed.

Burst capacity is NOT always available (sometimes DynamoDB uses it for background maintenance)

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

How many KB of data could be read in a second if a DynamoDB table is provisioned with 5 RCUs?

A

One read capacity unit represents one strongly consistent read per second, or two eventually consistent reads per second, for an item up to 4 KB in size.

Strongly consistent: 5 * 4 KB = 20KB

eventually consistent: 2 * 5 * 4 KB = 40 KB

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

If each data item is 2KB. How many items could be written if a DynamoDB table is provisioned with 6 WCUs in a second?

A

One write capacity unit represents one write per second for an item up to 1 KB in size.

6 1KB items in 1 second so
3 2KB items in 1 second

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

What is the DynamoDB max item size?

A

400KB

17
Q

What happens when a read or write request to a DynamoDB table is throttled?

A

The request fails with HTTP 400 code (bad request) and a ProvisionedThroughputExceededException.

The table does not have enough provisioned read/write capacity to support the operation.

18
Q

What is a Global Secondary Index?

A

A data structure that contains a subset of attributes from a table, along with an alternate key to support Query operations.

A global secondary index is considered “global” because queries on the index can span all of the data in the base table, across all partitions.

19
Q

What is a Local Secondary Index?

A

An index that has the same partition key as the base table, but a different sort key. A local secondary index is “local” in the sense that every partition of a local secondary index is scoped to a base table partition that has the same partition key value.

20
Q

Under what circumstances would you choose to implement a global secondary index?

A

When creating a new table, you have to select its primary key. If you need to query by other attributes, the request might take a long time e.g. you may need to scan the entire table to retrieve the information requested.

To speed up non-primary-key queries, DynamoDB offers Global Secondary Indexes (GSI) which increase the performance of these queries on non-key attributes.

21
Q

In relation to a global secondary index, what is a projection?

A

A projection is the set of attributes that is copied from a table into a secondary index.

The partition key and sort key of the table are always projected into the index; you can project other attributes to support your application’s query requirements. When you query an index, Amazon DynamoDB can access any attribute in the projection as if those attributes were in a table of their own.

22
Q

What is the difference between scan and query?

A

The query operation find items based on primary key values. It returns all the items with the specified partition key value.

Scan reads the entire database filtering out what’s not relevant. With scan, you can fetch items based on non primary key attributes.

Scan is more expensive than query.