Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Manage Read and Write Capacity Units in DynamoDB
📖 Scenario: You are managing a DynamoDB table for an online bookstore. To keep the database fast and cost-effective, you need to set the right read and write capacity units.
🎯 Goal: Learn how to create a DynamoDB table with specific read and write capacity units, then update those units as needed.
📋 What You'll Learn
Create a DynamoDB table named Books with a primary key ISBN (string).
Set the initial read capacity units to 5 and write capacity units to 10.
Create a variable called new_read_capacity and set it to 8.
Create a variable called new_write_capacity and set it to 15.
Write the code to update the Books table's provisioned throughput to the new capacity units.
💡 Why This Matters
🌍 Real World
Managing read and write capacity units helps keep DynamoDB tables responsive and cost-effective in real applications like online stores.
💼 Career
Understanding capacity units is important for database administrators and backend developers working with AWS DynamoDB to optimize performance and cost.
Progress0 / 4 steps
1
Create the DynamoDB table with initial capacity units
Create a DynamoDB table named Books with a primary key called ISBN of type string. Set the read capacity units to 5 and write capacity units to 10.
DynamoDB
Hint
Use dynamodb.create_table with ProvisionedThroughput to set capacity units.
2
Set new capacity unit variables
Create two variables: new_read_capacity set to 8 and new_write_capacity set to 15.
DynamoDB
Hint
Just assign the numbers to the variables as shown.
3
Get the existing table resource
Get the DynamoDB table resource for the Books table using dynamodb.Table('Books') and assign it to a variable called table.
DynamoDB
Hint
Use dynamodb.Table('Books') to get the table resource.
4
Update the table's provisioned throughput
Use the update method on the table variable to set the ProvisionedThroughput with ReadCapacityUnits equal to new_read_capacity and WriteCapacityUnits equal to new_write_capacity.
DynamoDB
Hint
Use table.update(ProvisionedThroughput={...}) with the new capacity variables.
Practice
(1/5)
1. What do read and write capacity units control in a DynamoDB table?
easy
A. The number of reads and writes the table can handle per second
B. The size of the data stored in the table
C. The number of tables in the database
D. The security settings of the table
Solution
Step 1: Understand capacity units meaning
Read and write capacity units define how many read and write operations a DynamoDB table can perform each second.
Step 2: Identify what capacity units control
They control throughput, not storage size, number of tables, or security settings.
Final Answer:
The number of reads and writes the table can handle per second -> Option A
Quick Check:
Capacity units = throughput control [OK]
Hint: Capacity units = max reads/writes per second [OK]
Common Mistakes:
Confusing capacity units with storage size
Thinking capacity units control security
Assuming capacity units limit number of tables
2. Which of the following is the correct way to specify write capacity units when creating a DynamoDB table using AWS CLI?
easy
A. --capacity ReadUnits=5,WriteUnits=10
B. --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=10
C. --throughput ReadCapacity=5 WriteCapacity=10
D. --provisioned-throughput ReadUnits=5 WriteUnits=10
Solution
Step 1: Recall AWS CLI syntax for capacity units
The correct syntax uses --provisioned-throughput with ReadCapacityUnits and WriteCapacityUnits keys.
Step 2: Match options with correct syntax
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=10 matches the exact syntax; others use incorrect keys or formats.
Final Answer:
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=10 -> Option B
Hint: Look for 'ReadCapacityUnits' and 'WriteCapacityUnits' keys [OK]
Common Mistakes:
Using incorrect keys like ReadUnits or WriteUnits
Missing commas or using wrong separators
Confusing throughput with capacity keywords
3. A DynamoDB table has 10 write capacity units. If each write item is 2 KB, how many writes per second can the table handle without throttling?
medium
A. 5 writes per second
B. 10 writes per second
C. 20 writes per second
D. 1 write per second
Solution
Step 1: Understand write capacity unit size
One write capacity unit allows one write per second for an item up to 1 KB.
Step 2: Calculate writes for 2 KB items
Each 2 KB item requires 2 write capacity units. With 10 units, 10 / 2 = 5 writes per second.
Final Answer:
5 writes per second -> Option A
Quick Check:
Write capacity units / item size factor = writes/sec [OK]
Hint: Divide capacity units by item size in KB [OK]
Common Mistakes:
Assuming 1 unit = 2 KB write
Not dividing capacity units by item size
Confusing read and write capacity units
4. You set a DynamoDB table's read capacity units to 5 but your application experiences throttling at 3 reads per second. What is the most likely cause?
medium
A. The table is in the wrong AWS region
B. The table has too many write capacity units
C. Each read item is larger than 4 KB, requiring more capacity units
D. The table's storage size is too large
Solution
Step 1: Recall read capacity unit size
One read capacity unit supports one strongly consistent read per second for an item up to 4 KB.
Step 2: Analyze throttling cause
If items are larger than 4 KB, each read consumes multiple units, so 5 units may not support 3 reads per second.
Final Answer:
Each read item is larger than 4 KB, requiring more capacity units -> Option C
Quick Check:
Item size affects read capacity usage [OK]
Hint: Check item size vs 4 KB read unit size [OK]
Common Mistakes:
Blaming write capacity units for read throttling
Ignoring item size impact on capacity
Thinking region or storage size causes throttling
5. You want to optimize costs for a DynamoDB table with variable traffic. Which approach best uses read and write capacity units efficiently?
hard
A. Set capacity units to zero when not using the table
B. Set very high fixed capacity units to avoid throttling
C. Manually increase capacity units once a month
D. Use on-demand capacity mode to automatically adjust units based on traffic
Solution
Step 1: Understand capacity modes
DynamoDB offers on-demand mode that adjusts capacity automatically to traffic, optimizing cost and performance.
Step 2: Compare options for cost efficiency
Setting high fixed units wastes money; manual changes are slow; zero units disables table. On-demand is best for variable traffic.
Final Answer:
Use on-demand capacity mode to automatically adjust units based on traffic -> Option D