Basics Flashcards
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)?
Primary Key
Indexes
What are the two different kinds of primary keys DynamoDB supports?
Partition Key
Partition Key and Sort Key
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?
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.
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?
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.
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?
partitions =
MAX(Table Size / 10GB,
(RCU desired/3000 + WCU desired, 1000))
How many write capacity units (WCU) can a single partition support?
1000
How many GB of data can a single partition handle?
10GB
When will DynamoDB add another partition to a table?
When one or more of the following occurs:
- more than 10GB of data stored
- more than 3000 RCUs
- more than 1000 WCUs
A good partition key will distribute the items evenly across the partitions. What 2 criteria can be used to make this choice?
Select an attribute..
- with as many distinct values as possible (employee ID better than department ID)
- 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 can you allocate more partitions to your table?
You can’t, you can only estimate and design accordingly. DynamoDB manages table partitioning for its users automatically.
How can you allocate more partitions to your table?
You can’t, you can only estimate and design accordingly. DynamoDB manages table partitioning for its users automatically.
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?
( 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
What is burst capacity?
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 many KB of data could be read in a second if a DynamoDB table is provisioned with 5 RCUs?
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
If each data item is 2KB. How many items could be written if a DynamoDB table is provisioned with 6 WCUs in a second?
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