0
0
DynamoDBquery~20 mins

TTL use cases (sessions, logs, cache) in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
TTL Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
TTL impact on session data expiration

You have a DynamoDB table storing user sessions with a TTL attribute set to expire sessions after 30 minutes. Which of the following describes the expected behavior of expired session items?

AExpired session items are archived automatically to another table before deletion.
BExpired session items remain in the table indefinitely until manually deleted.
CExpired session items are deleted eventually but not immediately after TTL time passes.
DExpired session items are immediately deleted from the table as soon as TTL time passes.
Attempts:
2 left
💡 Hint

Think about how DynamoDB handles TTL deletions asynchronously.

🧠 Conceptual
intermediate
2:00remaining
Choosing TTL for log data retention

You want to store application logs in DynamoDB and automatically remove logs older than 7 days. What is the best way to implement this using TTL?

ASet a TTL attribute on each log item with a timestamp 7 days after the log creation time.
BSet TTL attribute to the current time to delete logs immediately.
CUse a global secondary index to filter logs older than 7 days and delete them manually.
DManually scan and delete logs older than 7 days every hour.
Attempts:
2 left
💡 Hint

TTL works by specifying an expiration timestamp on each item.

📝 Syntax
advanced
2:00remaining
Correct TTL attribute format for cache expiration

Which of the following DynamoDB item attributes correctly sets TTL for cache expiration?

{
  "CacheKey": "item123",
  "Data": "some cached data",
  "ExpiresAt": ?
}
AExpiresAt: 1717262400
BExpiresAt: "12:00:00"
CExpiresAt: "2024-06-01T12:00:00Z"
DExpiresAt: true
Attempts:
2 left
💡 Hint

TTL attribute must be a Unix epoch time in seconds.

optimization
advanced
2:00remaining
Optimizing TTL usage for high write volume logs

You have a high volume of log entries written to DynamoDB with TTL set to 30 days. What is the best practice to optimize table performance and cost?

AUse a single large table with TTL enabled and no partition key changes.
BCreate multiple tables partitioned by month and enable TTL on each to reduce item scans.
CDisable TTL and manually delete old logs using batch operations.
DSet TTL to a very short time like 1 hour to reduce storage costs.
Attempts:
2 left
💡 Hint

Think about how partitioning affects performance and TTL cleanup.

🔧 Debug
expert
2:00remaining
Why are expired cache items not deleted as expected?

You set TTL on cache items with an attribute named "expiryTime" as Unix epoch seconds. After several days, expired items still appear in the table. What is the most likely cause?

ATTL attribute value is a string instead of a number.
BDynamoDB TTL deletes items only once per day, so delay is expected.
CTTL attribute value is set to a future timestamp instead of past.
DTTL attribute name in DynamoDB TTL settings does not match "expiryTime" exactly.
Attempts:
2 left
💡 Hint

Check the TTL attribute name configured in the table settings.