Jeff’s Note #
Unlike generic exam dumps, ADH analyzes this scenario through the lens of a Real-World Lead Developer.
For DVA-C02 candidates, the confusion often lies in choosing between manual deletion scripts and using DynamoDB’s TTL feature. In production, this is about understanding exactly how DynamoDB TTL operates asynchronously and when to leverage batch operations versus built-in expiration. Let’s drill down.
The Certification Drill (Simulated Question) #
Scenario #
BrightInk Publishing maintains a mobile app backend that stores millions of news articles daily in an Amazon DynamoDB table. Each article is represented as a single DynamoDB item. The app only displays articles that are less than 48 hours old. Articles older than 48 hours must be deleted automatically to minimize storage costs and maintain performance.
The Requirement: #
Identify the MOST cost-effective method for automatically deleting articles older than 48 hours.
The Options #
-
A) Add a String attribute with the article creation timestamp to each item. Write a script to scan and identify articles older than 48 hours using a full table scan. Use the BatchWriteItem API to delete old articles. Schedule this script on an Amazon EC2 instance using a cron job that runs hourly.
-
B) Add a String attribute with the article creation timestamp to each item. Write the deletion logic as a script inside a container image. Schedule an AWS Fargate task running on Amazon ECS to run the container every 5 minutes, performing a scan and batch delete of expired articles.
-
C) Add a Date attribute representing 48 hours after article creation. Create a global secondary index (GSI) with this attribute as the sort key. Implement a Lambda function triggered every minute by Amazon CloudWatch Events. This Lambda scans the GSI for expired articles and deletes them in batches using BatchWriteItem.
-
D) Add a Number attribute set to the timestamp 48 hours after article creation. Enable DynamoDB Time To Live (TTL) on this attribute to have DynamoDB automatically expire and delete items when the TTL timestamp passes.
Google adsense #
leave a comment:
Correct Answer #
D
Quick Insight: The Developer Imperative #
DynamoDB’s built-in TTL mechanism (Option D) allows fully managed, cost-effective asynchronous deletion of expired items without running custom scanning or batch deletion logic that consumes provisioned throughput or incurs compute costs. Always prefer TTL for automatic expiration when possible.
Content Locked: The Expert Analysis #
You’ve identified the answer. But do you know the implementation details that separate a Junior from a Senior?
The Expert’s Analysis #
Correct Answer #
Option D
The Winning Logic #
DynamoDB TTL provides an automatic, asynchronous item expiry mechanism that removes items without requiring active scans or delete API calls from your application. When you configure TTL on a Number attribute with a UNIX timestamp denoting the expiry time, DynamoDB periodically scans and deletes expired items behind the scenes, minimizing your operational overhead and cost. This is the most cost-effective and scalable way to enforce the 48-hour item lifetime rule for millions of posts daily.
- Using TTL shifts deletion responsibility to the managed service, avoiding hundreds or thousands of write delete API calls.
- No need for complex container orchestration or Cron-based EC2 scripts that incur additional compute, maintenance, and possible throughput costs.
- BatchWriteItem operations consume provisioned throughput and complicate retries, especially with large-scale data.
- This approach also ensures eventual consistent deletion that won’t impact table performance.
The Trap (Distractor Analysis): #
-
Why not Option A?
Running table scans and batch deletions on an EC2 cron job leads to high read capacity consumption and compute cost. It also requires manual scheduling and scaling management. -
Why not Option B?
Running an ECS Fargate task every 5 minutes is better than EC2 in flexibility but still inefficient and costly compared to TTL. Scanning a large table frequently drives costs up and requires managing container lifecycle. -
Why not Option C?
Creating a GSI on the expiry timestamp incurs additional storage and write costs. Lambda-driven batch deletes again consume provisioned throughput and introduce complexity. Also, Lambda execution limits and retries must be handled carefully under scale.
The Technical Blueprint #
# Example CLI command to enable TTL on a DynamoDB table
aws dynamodb update-time-to-live \
--table-name BrightInkArticles \
--time-to-live-specification Enabled=true,AttributeName=expiryTimestamp
The Comparative Analysis #
| Option | API Complexity | Performance Impact | Use Case |
|---|---|---|---|
| A | Medium (BatchWriteItem + scans) | High (full table scans on EC2) | Legacy/manual deletion with fixed server |
| B | Medium (BatchWriteItem + scans in Fargate) | High (frequent scans + Lambda execution) | Containerized batch deletion, moderate automation |
| C | High (GSI + Lambda + BatchWriteItem) | Medium (index overhead, Lambda limits) | Index-driven purging, serverless with complexity |
| D | Low (native TTL config) | Low (asynchronous, managed by DynamoDB) | Automated, low-maintenance expiry using TTL |
Real-World Application (Practitioner Insight) #
Exam Rule #
“For the exam, always pick DynamoDB TTL when you see the keyword ‘automatic deletion of expired items’ in a DynamoDB table scenario.”
Real World #
In large-scale systems, TTL is often paired with DynamoDB Streams and Lambda to trigger side effects upon deletion (e.g., analytics updates). However, the core deletion responsibility rests with TTL for optimal cost and operational simplicity.
(CTA) Stop Guessing, Start Mastering #
Disclaimer
This is a study note based on simulated scenarios for the AWS DVA-C02 exam.