Please answer the quiz and click the "Test" button at the bottom right.This quiz is part of the DevOpsTheHardWay course.
AWS - DynamoDB - multichoice questions
Question 1
You are designing a highly scalable application that utilizes DynamoDB for its database needs. The application is expected to handle a maximum of 1000 reads/second and 500 writes/second. Items average size is 4 KB.
How many RCU and WCU are required?
- 500 RCU and 2000 WCU
- 2000 RCU and 500 WCU
- 1000 RCU and 500 WCU
- 500 RCU and 1000 WCU
Question 2
You're team is developing a news website that receives an average of 500 read requests per second during peak hours. Each news article is approximately 10 KB in size.
Which of the following is a proper DB design?
- Autoscale read capacity from min of 1 to max of 250.
- Autoscale read capacity from min of 1 to max of 750.
- Autoscale read capacity from min of 1 to max of 1000.
- Autoscale read capacity from min of 1 to max of 500.
Question 3
Consider the following JSON sample of an item in an DynamoDB table:
{
"item_id": "123456789",
"timestamp": "2022-05-10T10:30:00Z",
"name": "Product A",
"category": "Electronics",
"price": 99.99,
"quantity": 10
}
Which attribute from the item JSON sample would be most suitable as the partition key for the DynamoDB table?
-
item_id
-
name
-
category
-
price
Question 4
Consider a scenario for an e-commerce site that uses DynamoDB to store orders data. The most common query is retrieval of order history per customer.
What would be the most suitable choice for the primary key?
-
customerID
as a partition key only. -
orderID
as a partition key only. -
customerID
as a partition key andorderID
as a sort key. -
orderID
as a partition key andcustomerID
as a sort key.
Suppose you have a DynamoDB table named "ProductCatalog" designed to store product information.
The table has a primary key ProductID
and a global secondary index (GSI) named CategoryIndex
with the partition key Category
and sort key ProductID
.
Answer the below 2 questions.
Question 5
You've just written a new product data into the table. Then, immediately, retrieve the data, as follows:
import boto3
# Initialize DynamoDB client
dynamodb = boto3.client('dynamodb')
# Write data to the table
dynamodb.put_item(
TableName='ProductCatalog',
Item={
'ProductID': {'S': '123'},
'Name': {'S': 'Example Product'},
'Category': {'S': 'Electronics'}
}
)
# Retrieve the data
response = dynamodb.get_item(
TableName='ProductCatalog',
Key={
'ProductID': {'S': '123'}
},
ConsistentRead=True # Ensure strong consistency
)
print(response['Item'])
What data would be returned by this code?
- The newly written product data as it has been retrieved using the GSI key and strongly consistency.
- Either the newly written product data or an older one, as it has been retrieved using the GSI key and eventually consistency.
- The newly written product data as it has been retrieved using the primary key and strongly consistency.
- Either the newly written product data or an older version of the product data, as it has been retrieved using the primary key and eventually consistency.
- An error will be raised.
Question 6
You've just written a new product data into the table. Then, immediately, retrieve the data using the GSI and strongly consistent read.
What would be the outcome of this action?
- The newly written product data will be retrieved using the GSI with strongly consistent read.
- No data will be returned due to the attempt to use GSI with strongly consistent read.
- Either the newly written product data or an older version of the product data would be returned.
- An error will be raised.
Question 7
Consider a DynamoDB table with 4 partitions, each containing items:
Partition 1:
[
{
"ProductID": "125",
"Name": "Laptop Pro X",
"Category": "Electronics"
},
{
"ProductID": "173",
"Name": "Phone XS Max",
"Category": "Electronics"
},
{
"ProductID": "199",
"Name": "Keyboard K2",
"Category": "Electronics"
}
]
Partition 2:
[
{
"ProductID": "201",
"Name": "Jacket XL",
"Category": "Clothes"
},
{
"ProductID": "262",
"Name": "Shirt M",
"Category": "Clothes"
}
]
Partition 3:
[
{
"ProductID": "121",
"Name": "Sneakers 10",
"Category": "Footwear"
},
{
"ProductID": "234",
"Name": "Sandals",
"Category": "Footwear"
},
{
"ProductID": "301",
"Name": "Boots 8",
"Category": "Footwear"
}
]
Partition 4:
[
{
"ProductID": "319",
"Name": "Belt M",
"Category": "Accessories",
"Description": "Genuine leather"
},
{
"ProductID": "433",
"Name": "Sunglasses XL",
"Category": "Accessories",
"Description": "Polarized lenses"
},
{
"ProductID": "455",
"Name": "Watch S",
"Category": "Accessories",
"Description": "Water-resistant"
},
{
"ProductID": "728",
"Name": "Bracelet Gold",
"Category": "Accessories",
"Description": "18k gold plated"
}
]
Now, a new item is added to the table with the following data:
{
"ProductID": "501",
"Name": "Backpack",
"Category": "Accessories",
"Description": "Laptop compartment"
}
Without knowing the primary key of the table, which partition this new item is most likely to be mapped to?
- Partition 1
- Partition 2
- Partition 3
- Partition 4