Lesson 5 of 7 Amazon S3 Data Lakes

Reducing Storage Cost with S3 Storage Classes and Lifecycle Rules

This lesson explains how S3 storage classes and lifecycle rules keep each object in the cheapest class that meets its access needs as it ages, and delete it when it is no longer needed, without manual work.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose a storage class from access patterns.
  • Write lifecycle transition and expiration rules.
  • Identify transition costs and minimum storage durations.

Storage classes

S3 storage classes trade a lower storage price against retrieval cost and speed. S3 Standard suits data accessed frequently, such as the curated and consumption zones. S3 Intelligent-Tiering monitors each object and moves it between access tiers automatically, with no retrieval fees, which suits data whose access pattern is unknown or changing. Standard-IA and One Zone-IA (infrequent access) cost less to store but charge per gigabyte retrieved and bill at least 30 days; One Zone-IA keeps data in a single Availability Zone, so it suits only data that can be recreated.

The Glacier classes are for archives. Glacier Instant Retrieval returns data in milliseconds, Glacier Flexible Retrieval in minutes to hours, and Glacier Deep Archive, the cheapest, within about 12 hours. They have retrieval fees and minimum storage periods of 90 or 180 days. Lifecycle rules move ageing raw data down these classes automatically. The following table summarises the classes.

ClassUse for
S3 StandardFrequent access
Intelligent-TieringUnknown or changing access patterns; moves objects between tiers automatically
Standard-IA, One Zone-IAInfrequent access, with retrieval fees and a 30-day minimum
Glacier Instant Retrieval, Flexible Retrieval, Deep ArchiveArchives: lower storage cost, with retrieval fees, delays and 90 or 180-day minimums

30days

Minimum billed for Standard-IA and One Zone-IA

90days

Minimum for Glacier Instant and Flexible Retrieval

180days

Minimum for Glacier Deep Archive

12hours

About how long a Deep Archive retrieval takes

Sort into groups

Which storage class?

Exam skills 2.1.1 · 2.3.2

Choose the S3 storage class for each dataset.

Log in to try this activity Interactive activities are free with an account.

Lifecycle rules

Lifecycle rules manage storage cost automatically, applying to objects selected by prefix or tag. A transition action moves objects to a cheaper storage class after a set age, for example moving raw data to S3 Glacier Flexible Retrieval 90 days after it was processed. An expiration action deletes objects once their retention period ends.

Two further actions clean up storage that is easy to forget. In versioned buckets, rules delete noncurrent versions after a period, so overwritten and deleted objects do not accumulate indefinitely. And rules abort incomplete multipart uploads after a few days, because the parts of uploads that never finished remain stored, and billed, but invisible in ordinary listings.

The following diagram shows each data lake zone's storage classes over seven years.

The lifecycle rules for each zone over seven years. Raw data stays in S3 Standard for 90 days, moves to Glacier Flexible Retrieval and expires after seven years. Curated data is in Intelligent-Tiering from creation and expires after three years. Athena query results expire after seven days, and incomplete multipart uploads are aborted after seven days in every bucket.
The time axis uses a square-root scale so that short periods remain visible.
Match the pairs

Lifecycle actions

Exam skills 2.3.2 · 2.3.3

Match each requirement with the lifecycle action.

Log in to try this activity Interactive activities are free with an account.

Points to watch

Lifecycle transitions have costs and constraints that can make a rule more expensive than it looks. Each transition is charged per object, so archiving millions of tiny files can cost more in transition requests than it ever saves in storage; such files should be compacted first.

Colder storage classes also have minimum storage durations, for example 90 days for S3 Glacier Flexible Retrieval, and objects deleted or moved before that period are charged for the remainder. Finally, data that is still queried, for example by Athena, must stay in a class with immediate access, because archive classes require a restore before the data can be read.

True or false

Lifecycle pitfalls

Exam skills 2.3.2 · 1.2.4

Decide whether each statement about lifecycle rules is true.

Log in to try this activity Interactive activities are free with an account.
Worked example

A lifecycle policy for each zone

A data lake keeps raw data for seven years for audit, but reads it only when reprocessing. Curated data is queried heavily for a year. The lifecycle rules for each zone are shown in the following table.

ZoneLifecycle rule
RawTransition to Glacier Flexible Retrieval after 90 days; expire after 7 years
CuratedIntelligent-Tiering from creation; expire after 3 years
Athena query resultsExpire after 7 days
All bucketsAbort incomplete multipart uploads after 7 days

Raw files are compacted before transition, because transitions are charged per object. Reprocessing raw data older than 90 days then requires a restore, which the team accepts for audit-only data.

Check yourself

How is data deleted automatically at the end of its retention period?

Show answer

With an S3 lifecycle expiration rule.

Exam Tips

Remember for the exam

  • To move cold partitions to Glacier automatically, use a lifecycle transition rule.
  • To delete data after its retention period, use lifecycle expiration.
  • Unknown or changing access patterns suit S3 Intelligent-Tiering.
  • To clean up abandoned uploads, add a rule that aborts incomplete multipart uploads.
  • Compact small files before archiving them, because transitions are charged per object.