Bird
Raised Fist0
DynamoDBquery~20 mins

TTL behavior and timing in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
TTL Timing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
When does DynamoDB delete expired items?

In DynamoDB, after an item's TTL timestamp passes, when will DynamoDB delete that item?

AAt the end of each day during a scheduled cleanup window.
BImmediately at the exact second the TTL timestamp is reached.
COnly when a read or write operation accesses the expired item.
DWithin 48 hours after the TTL timestamp has passed, but timing is not guaranteed.
Attempts:
2 left
💡 Hint

Think about how background processes work asynchronously in cloud services.

❓ query_result
intermediate
2:00remaining
Effect of TTL on Query Results

You have a DynamoDB table with TTL enabled on attribute expireAt. You run a Query operation immediately after an item's TTL timestamp has passed but before DynamoDB deletes it. What will the Query return?

AThe expired item will be returned because it still exists in the table.
BThe expired item will not be returned because TTL hides expired items instantly.
CThe Query will return an error due to expired items.
DThe Query will return only the expired item and no others.
Attempts:
2 left
💡 Hint

Consider when DynamoDB physically removes expired items versus when they expire logically.

📝 Syntax
advanced
2:00remaining
Correct TTL Attribute Format

Which of the following DynamoDB item attributes is correctly formatted for TTL to work?

DynamoDB
Item example: { "id": "123", "expireAt": ??? }
A"expireAt": "June 1, 2024 12:00:00"
B"expireAt": "2024-06-01T12:00:00Z"
C"expireAt": 1711896000
D"expireAt": true
Attempts:
2 left
💡 Hint

TTL expects a specific type of timestamp value.

❓ optimization
advanced
2:00remaining
Reducing Delay in TTL Deletion

You want expired items to be deleted as soon as possible after TTL expiration. Which approach can help reduce the delay?

AIncrease the TTL timestamp by a few hours to batch deletions.
BEnable DynamoDB Streams and process expired items manually to delete them faster.
CDisable TTL and delete expired items with a scheduled Lambda function only.
DSet the TTL attribute to a string date format for faster processing.
Attempts:
2 left
💡 Hint

Think about how you can react to changes in the table immediately.

🔧 Debug
expert
2:00remaining
Why are expired items not deleted after 48 hours?

You enabled TTL on your DynamoDB table with attribute expireAt. Some items have expired more than 48 hours ago but still appear in the table. What is the most likely reason?

AThe TTL attribute is missing or has incorrect data type on those items.
BDynamoDB deletes expired items only during monthly maintenance windows.
CThe table's read capacity is too low to allow TTL deletions.
DExpired items are never deleted automatically; TTL only marks them.
Attempts:
2 left
💡 Hint

Check the attribute format and presence carefully.

Practice

(1/5)
1. What does TTL (Time To Live) do in DynamoDB?
easy
A. Encrypts data stored in the table.
B. Backs up data periodically.
C. Automatically deletes items after their expiration time.
D. Indexes data for faster queries.

Solution

  1. Step 1: Understand TTL purpose

    TTL is designed to remove expired data automatically to save storage and keep data fresh.
  2. Step 2: Identify TTL behavior

    It deletes items after their expiration timestamp passes, not encrypting or backing up data.
  3. Final Answer:

    Automatically deletes items after their expiration time. -> Option C
  4. Quick Check:

    TTL = automatic deletion [OK]
Hint: TTL means automatic deletion after expiry [OK]
Common Mistakes:
  • Thinking TTL encrypts data
  • Confusing TTL with backup
  • Assuming TTL speeds up queries
2. Which attribute type must the TTL attribute have in DynamoDB?
easy
A. String representing a date in ISO format
B. Number representing Unix epoch time in seconds
C. Boolean indicating if item is expired
D. List of timestamps

Solution

  1. Step 1: Recall TTL attribute format

    The TTL attribute must be a number storing the expiration time as Unix epoch seconds.
  2. Step 2: Eliminate other types

    Strings, booleans, or lists are not valid for TTL expiration timestamps.
  3. Final Answer:

    Number representing Unix epoch time in seconds -> Option B
  4. Quick Check:

    TTL attribute = Unix epoch seconds [OK]
Hint: TTL attribute stores expiration as Unix epoch seconds [OK]
Common Mistakes:
  • Using string dates instead of numbers
  • Using boolean instead of timestamp
  • Trying to store multiple timestamps
3. If an item has a TTL attribute set to 1650000000 (Unix epoch seconds), when will DynamoDB delete it?
medium
A. Within 48 hours after 1650000000 seconds
B. Exactly at 1650000000 seconds
C. Immediately after setting the TTL attribute
D. Only when manually deleted

Solution

  1. Step 1: Understand TTL deletion timing

    DynamoDB deletes expired items approximately after the TTL timestamp, not exactly at that second.
  2. Step 2: Recall deletion delay

    Deletion can take up to 48 hours after the expiration time to occur.
  3. Final Answer:

    Within 48 hours after 1650000000 seconds -> Option A
  4. Quick Check:

    TTL deletion delay = up to 48 hours [OK]
Hint: TTL deletion can be delayed up to 48 hours [OK]
Common Mistakes:
  • Expecting deletion exactly at expiration time
  • Thinking deletion is immediate
  • Assuming manual deletion is required
4. You set TTL on an attribute but notice expired items are not deleted after 3 days. What is a likely cause?
medium
A. TTL attribute is not a number with Unix epoch seconds
B. TTL is enabled but the table is in a different AWS region
C. You forgot to enable encryption on the table
D. The table has no primary key

Solution

  1. Step 1: Check TTL attribute format

    If the TTL attribute is not a number with Unix epoch seconds, DynamoDB ignores it for expiration.
  2. Step 2: Verify other options

    Region difference, encryption, or primary key absence do not prevent TTL deletion.
  3. Final Answer:

    TTL attribute is not a number with Unix epoch seconds -> Option A
  4. Quick Check:

    TTL attribute format error blocks deletion [OK]
Hint: TTL attribute must be Unix epoch number [OK]
Common Mistakes:
  • Assuming region affects TTL
  • Thinking encryption affects TTL
  • Ignoring TTL attribute data type
5. You want to ensure items expire exactly after 24 hours using TTL. Which approach is best considering DynamoDB's TTL behavior?
hard
A. Disable TTL and run a scheduled job to delete expired items
B. Set TTL attribute to current time + 86400 seconds and manually delete items after 24 hours
C. Use a string date format for TTL attribute for precise timing
D. Set TTL attribute to current time + 86400 seconds and accept up to 48-hour deletion delay

Solution

  1. Step 1: Understand TTL timing limits

    DynamoDB TTL deletes items approximately after expiration, with up to 48 hours delay.
  2. Step 2: Choose best practical approach

    Setting TTL attribute to current time + 86400 seconds (24 hours) is correct; manual deletion adds complexity and string format is invalid.
  3. Step 3: Consider alternatives

    Disabling TTL and scheduling deletes is possible but less efficient than TTL's automatic deletion.
  4. Final Answer:

    Set TTL attribute to current time + 86400 seconds and accept up to 48-hour deletion delay -> Option D
  5. Quick Check:

    TTL delay means accept approximate expiry [OK]
Hint: TTL deletion timing is approximate, plan accordingly [OK]
Common Mistakes:
  • Expecting exact deletion timing
  • Using string instead of number for TTL
  • Disabling TTL unnecessarily
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard