0 votes
in AWS by

An application hosted in AWS has been configured to use a DynamoDB table. Several items are written to the DynamoDB table. These items are only accessed in a particular time frame, after which they can be deleted.

Which of the following is an ideal way to manage the deletion of the stale items?

1 Answer

0 votes
by

Answer - D.

The AWS Documentation mentions the following.

Time To Live (TTL) for DynamoDB allows you to define when items in a table expire so that they can be automatically deleted from the database.

TTL is provided at no extra cost as a way to reduce storage usage and reduce the cost of storing irrelevant data without using provisioned throughput.

With TTL enabled on a table, you can set a timestamp for deletion on a per-item basis, allowing you to limit storage usage to only those records that are relevant.

Options A and B are incorrect since these would not be cost-effective and have a performance issue on the underlying DynamoDB table.

Option C is incorrect since versioning is not possible in DynamoDB.For more information on Time to Live for items in DynamoDB, please refer to the below Link-

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html

The ideal way to manage the deletion of stale items from a DynamoDB table is to enable Time-to-Live (TTL) feature for the items in the table. The correct answer is D.

TTL is a feature that allows you to specify a time period for the items in a DynamoDB table to live. When an item expires, DynamoDB automatically deletes it from the table. This feature is useful for scenarios where data becomes stale after a certain period of time and is no longer needed.

To enable TTL for items in a DynamoDB table, you need to create a new attribute in the table that stores the expiration time for each item. This attribute must be a Unix timestamp, which represents the number of seconds since January 1, 1970, UTC. Once you have created this attribute, you can enable TTL for the table by configuring it in the table settings.

When TTL is enabled for a DynamoDB table, expired items are automatically deleted from the table. DynamoDB checks the expiration time of each item and deletes it if the current time is greater than or equal to the expiration time. This process is performed asynchronously and does not affect the performance of the table.

Option A, performing a scan on the table for the stale items and issuing the Delete operation, is not an ideal way to manage the deletion of stale items because it can be slow and expensive for large tables. Scans are not efficient for large tables as they read every item in the table, which can result in a high read capacity consumption and increased cost.

Option B, creating an additional column to store the date and performing a query for the stale objects and then performing the Delete operation, can work, but it requires additional management and maintenance of the table. You need to ensure that the expiration date attribute is updated correctly and that the query for stale objects is performed efficiently.

Option C, enabling versioning for the items in DynamoDB and deleting the last accessed version, is not an ideal way to manage the deletion of stale items because it does not guarantee that the deleted version of the item is the stale one. Versioning in DynamoDB allows you to keep track of multiple versions of an item, but it does not provide a way to determine which version is stale or expired.

...