
Answer-first summary for fast verification
Answer: Add a Number type attribute to each item, set to the expiration time 48 hours post-creation. Enable DynamoDB's TTL feature using this attribute to automatically delete expired items.
The correct answer is D. DynamoDB's Time to Live (TTL) feature is the most cost-effective method for automatically deleting items that are older than a specified timeframe. By adding a Number type attribute to each item, set to the expiration time 48 hours post-creation, and configuring the DynamoDB table to use this attribute for TTL, the items will be automatically deleted when they expire. This approach eliminates the need for custom scripts, additional AWS services, or manual intervention, making it the most efficient and cost-effective solution.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
In a mobile app using Amazon DynamoDB to store blog posts, with millions added daily, identify the most cost-effective method to automatically delete posts older than 48 hours.
A
Add a timestamp attribute to each item, indicating creation time. Develop a script for a table scan to identify and remove posts older than 48 hours using BatchWriteItem. Schedule execution hourly on an EC2 instance.
B
Introduce a timestamp attribute for creation time in each item. Develop a script for a table scan to identify and remove posts older than 48 hours using BatchWriteItem. Containerize the script and run it every 5 minutes on AWS Fargate via ECS.
C
Add a Date type attribute to each item, set to 48 hours post-creation. Create a GSI using this attribute as a sort key. Develop a Lambda function to reference the GSI and remove expired items with BatchWriteItem, triggered every minute by a CloudWatch event.
D
Add a Number type attribute to each item, set to the expiration time 48 hours post-creation. Enable DynamoDB's TTL feature using this attribute to automatically delete expired items.
No comments yet.