SysDesignPrep.com
Interactive concepts

Storage tiering and lifecycle rules for hot, warm and cold data: an interactive cost simulator

Object stores offer several storage classes. The cheaper ones store a gigabyte for a fraction of the price but charge to read it back, and the cheapest make a read wait hours. Lifecycle rules move objects to cheaper classes as they age. Whether that saves money depends entirely on how often old data is still read.

The playground stores 30 TB of new images a month for three years, about a petabyte in the end, under four policies, with approximate S3 prices. Switch between user photos, which go cold within weeks, and product images, which are read steadily forever.

30 TB of user photos arrive every month for three years, about 1 PB in the end. Kept in Standard, the bill grows to $24,840 a month. Most photos go cold within weeks, so moving them to Infrequent Access and then Glacier Instant Retrieval cuts the last month to $6,195 and three years from $460K to $142K, still answering every read in milliseconds. Deep Archive is cheaper still, $112K, but 26% of all views then wait up to 12 hours for a restore: fine for backups, unacceptable for a photo someone taps on.

$0$15,000$30,000month 1month 13month 25month 36
Everything in StandardInfrequent Access at 30 daysIA at 30 days, Glacier IR at 90Deep Archive at 90 days
Everything in Standardno lifecycle rules
Month 36 bill
$24,840
of which retrieval
$0
Three years
$460K
Views waiting hours
0%
Infrequent Access at 30 daysStandard, then IA
Month 36 bill
$14,146
of which retrieval
$231
Three years
$271K
Views waiting hours
0%
IA at 30 days, Glacier IR at 90Standard, IA, Glacier Instant Retrieval
Month 36 bill
$6,195
of which retrieval
$495
Three years
$142K
Views waiting hours
0%
Deep Archive at 90 daysStandard, then Deep Archive
Month 36 bill
$3,815
of which retrieval
$265
Three years
$112K
Views waiting hours
26%
Standard, $0.023/GB-moInfrequent Access, $0.0125/GB-mo, $0.01/GB readGlacier Instant Retrieval, $0.004/GB-mo, $0.03/GB readGlacier Deep Archive, $0.00099/GB-mo, $0.02/GB read

When tiering pays

  • Cold data is where the money is. For user photos, keeping everything in Standard costs about $460K over three years. Moving photos to Infrequent Access after 30 days and Glacier Instant Retrieval after 90 cuts that to about $142K, and every read still returns in milliseconds.
  • Deep archive is for data nobody waits for. Deep Archive takes it to about $112K, but about a quarter of all views would then wait up to 12 hours for a restore. It suits backups, compliance archives and raw logs, not anything a user can click on.
  • Retrieval fees punish warm data. Product images read 1.5 times a month at any age cost more in every cheaper class: $548K in Infrequent Access and $917K in Glacier Instant Retrieval against $460K in Standard, because each read pays a per-gigabyte fee that the storage saving cannot cover.
  • Small objects and short lives cost extra. Transitions are charged per object, and the cheaper classes bill a minimum size and a minimum storage duration, so millions of tiny files, or files deleted soon after moving, can cost more than they save.

A lifecycle configuration

{
  "Rules": [{
    "ID": "photos-cool-down",
    "Filter": { "Prefix": "photos/" },
    "Status": "Enabled",
    "Transitions": [
      { "Days": 30, "StorageClass": "STANDARD_IA" },
      { "Days": 90, "StorageClass": "GLACIER_IR" }
    ]
  }, {
    "ID": "backups-to-archive",
    "Filter": { "Prefix": "backups/" },
    "Status": "Enabled",
    "Transitions": [{ "Days": 7, "StorageClass": "DEEP_ARCHIVE" }],
    "Expiration": { "Days": 2555 }
  }]
}

When access patterns are unknown, an automatic class such as S3 Intelligent-Tiering watches each object and moves it between tiers for a small monitoring fee per object, which works well for large objects with unpredictable access.

In a system design interview

When the estimate reaches petabytes, say how the bill is controlled: “Photos are read heavily in their first weeks, so after 30 days a lifecycle rule moves them to infrequent access and after 90 days to an instant-retrieval archive class; reads stay fast and the storage bill drops by about three quarters. Original uploads we only need for reprocessing go to deep archive. Thumbnails stay in the standard class because they are read constantly.” Expect the follow-ups: what happens when an old photo goes viral, how deletes interact with minimum durations, and whether a CDN in front changes the read pattern the store sees.

Read the guide to object storage and files or cost optimisation, see erasure coding and CDN caching, or watch a strong candidate design Instagram.

Questions people ask

What is storage tiering?

Keeping data in different storage classes according to how often it is accessed: hot data in fast, more expensive storage and cold data in cheaper storage that costs more to read or takes longer to return. Lifecycle rules move data between tiers as it ages.

What are S3 lifecycle rules?

Bucket configuration that transitions objects to cheaper storage classes after a number of days, or deletes them, optionally filtered by prefix or tag. They automate moving data from Standard to Infrequent Access, Glacier classes and Deep Archive as it cools.

When does Infrequent Access cost more than Standard?

When data is read often enough that the per-gigabyte retrieval fee exceeds the storage saving. With storage about $0.0105 per GB-month cheaper and retrieval about $0.01 per GB, reading an object about once a month or more removes the saving, and minimum durations and object sizes add to the cost.

What is the difference between Glacier Instant Retrieval and Deep Archive?

Glacier Instant Retrieval returns data in milliseconds at a low storage price but a higher retrieval fee, suiting rarely read data that must stay instantly available. Deep Archive is the cheapest storage but needs a restore that takes hours, suiting backups and compliance archives.

What is S3 Intelligent-Tiering?

A storage class that monitors each object’s access and moves it automatically between frequent, infrequent and archive instant tiers, with no retrieval fees but a small monthly monitoring fee per object. It suits large objects with unknown or changing access patterns.

How do you choose storage classes in a system design?

Estimate how reads fall off with age. Keep data that is read constantly, such as thumbnails, in the standard class; move data that goes cold after weeks to infrequent or instant-archive classes; and put data that is only needed in emergencies in deep archive.

What happens when archived data suddenly becomes popular?

Reads from cheaper classes pay retrieval fees, and deep archive objects must be restored first, which takes hours. Systems put a CDN or cache in front of storage so a sudden spike is served from the cache, and can copy hot objects back to the standard class.