CloudArcade

Guided architecture tour · 6–8 min

Let old practice records retire — DynamoDB TTL

Clean up expired practice records while keeping access checks correct.

This tour teaches architecture decisions. Its services are not provisioned in the emulator.

Your goal

Clean up expired practice records while keeping access checks correct.

Why this matters

A quiz app keeps temporary sessions that are no longer useful after a day. You will mark their expiry, understand cleanup delays, and prevent expired sessions from being accepted.

Words you will use

TTL means time to live. An expiry timestamp says when a record becomes old. Unix time in seconds is a numeric count of seconds from a standard starting point.

How to proceed

Read each situation and choose an answer. The lesson explains the result. Try again if needed, then continue through all three decisions and finish the tour.

Play this architecture tour

1. Store the right expiry value

The table has TTL enabled for expiresAt. A new practice session should expire tomorrow. Choose a value format that DynamoDB can use.

What should expiresAt contain?

A number containing Unix time in seconds.

TTL uses a numeric timestamp in seconds. A readable date string or a timestamp in milliseconds is not the same value. Calculate the intended expiry and store it in the configured field.

The record has an expiry value the cleanup feature understands.

expiresAt: numeric Unix timestamp in seconds

2. Separate expiry from deletion

The expiry time has passed, but a read still returns the record. The team wonders whether the clock is broken. Choose the behavior to account for.

When does TTL remove an expired item?

Later, through background cleanup that can take days.

TTL deletion is not an exact timer. Expired items can remain while cleanup waits to run. A useful app must handle them correctly during that delay instead of assuming they are already gone.

The team expects background cleanup rather than instant removal.

Expiry reached → item may remain → background deletion

3. Reject an expired session

An old quiz session still exists in the table during the cleanup delay. The user tries to use it again. Choose the rule that should decide access.

What must the app check?

Compare expiresAt with the current time before accepting it.

Cleanup and access control solve different jobs. The app must reject an expired session immediately according to its own rules, even while the storage service still holds the record.

An old session cannot be reused just because cleanup has not finished.

Read record → check expiry → accept or reject

Practice, then check your understanding

In the interactive tour, make each decision before seeing the outcome. Wrong answers receive coaching, and replay gives you a fresh attempt without duplicating earned XP.

Read the official AWS documentation for service behavior and production details.

Continue with another AWS learning guide