0
0
DynamoDBquery~10 mins

Hot partition prevention in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the partition key attribute in a DynamoDB table creation.

DynamoDB
KeySchema=[{'AttributeName': '[1]', 'KeyType': 'HASH'}]
Drag options to blanks, or click blank then click option'
ARegion
BTimestamp
CSortKey
DUserId
Attempts:
3 left
💡 Hint
Common Mistakes
Using a timestamp as partition key can cause hot partitions.
Using a sort key as partition key is incorrect.
2fill in blank
medium

Complete the code to add a sort key to the DynamoDB table schema.

DynamoDB
KeySchema=[{'AttributeName': 'UserId', 'KeyType': 'HASH'}, {'AttributeName': '[1]', 'KeyType': 'RANGE'}]
Drag options to blanks, or click blank then click option'
ATimestamp
BUserId
CRegion
DStatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same attribute as partition and sort key.
Choosing an attribute with low cardinality as sort key.
3fill in blank
hard

Fix the error in the partition key design to prevent hot partitions by using a composite key pattern.

DynamoDB
PartitionKey = userId + '[1]'
Drag options to blanks, or click blank then click option'
AUserId
BRegion
CStatus
DTimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Concatenating timestamp can cause uneven distribution if timestamps cluster.
Using the same attribute twice in the key.
4fill in blank
hard

Fill both blanks to create a partition key that includes a user ID and a hashed value to spread load evenly.

DynamoDB
PartitionKey = '[1]' + '#' + hash([2])
Drag options to blanks, or click blank then click option'
AUserId
BTimestamp
CRegion
DStatus
Attempts:
3 left
💡 Hint
Common Mistakes
Hashing the user ID instead of timestamp.
Using attributes with low variability.
5fill in blank
hard

Fill all three blanks to create a DynamoDB item with a partition key, sort key, and an attribute to prevent hot partitions.

DynamoDB
Item = {'PartitionKey': [1], 'SortKey': [2], 'Region': [3]
Drag options to blanks, or click blank then click option'
A'UserId#' + str(hash(userId))
BTimestamp
C'us-east-1'
D'Status'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plain user ID without hashing for partition key.
Using a non-time attribute as sort key.
Not including region or similar attribute for distribution.