‹ All SAP-C02 questions

SAP-C02 Practice Question 94: DynamoDB TTL Session Expiry

AWS Certified Solutions Architect – Professional (SAP-C02) · Test 10 · question 4 of 10

Design for New Solutionsmedium

A web application stores user sessions in Amazon DynamoDB. A session must stop being honored 30 minutes after the user's last activity, and expired sessions must be cleaned up automatically without consuming write capacity or requiring a scheduled cleanup job. The security team also requires that a session is never accepted after it has expired, even if the item is still in the table.

Which design meets these requirements?

Select one answer
Show answer and explanation

Answer:

  • A. Enable TTL on a Number attribute that holds the expiry as Unix epoch seconds, and have the application also check the expiry time on every read

DynamoDB TTL *"allows you to define a per-item expiration timestamp"* and *"automatically deletes expired items within a few days of their expiration time, without consuming write throughput."* The timestamp *"must be stored as a Number data type in Unix epoch time format at the seconds granularity."* Because deletion is not immediate, AWS notes that *"items with valid, expired TTL attributes might be deleted by the system at any time, typically within a few days after their expiration"*, and recommends using filter expressions to remove expired items from query and scan results. Checking the expiry on read ensures that an expired session is never accepted (option A).

- B is wrong because an expired item can remain in the table for days, so treating presence as validity would accept expired sessions and violate the security requirement. - C is wrong because *"items with a TTL attribute that is not a Number type are ignored by the TTL process,"* so nothing would ever be deleted. - D is wrong because a scheduled scan consumes read and write capacity and needs a job to run, both of which the company wants to avoid.

Reference: Using time to live (TTL) in DynamoDB

Practice Test 10 ›

Study guides for SAP-C02