DEV Community

BytePatterns
BytePatterns

Posted on Edited on Originally published at bytepatterns.com

Amazon S3 Consistency, Storage Classes & Lifecycle Rules Explained

Amazon S3 is one of the first services every cloud engineer touches — and one of the most frequently tested in AWS Solutions Architect (SAA-C03) and Data Engineer interviews. Knowing which storage class to pick, how read-after-write consistency works, and when lifecycle rules actually save money can prevent painful surprise bills.


1. Strong Read-After-Write Consistency (Not Eventual!)

For years, engineers had to memorize S3's eventual consistency caveats for overwrites and deletes. That is no longer the case.

Today, S3 provides strong read-after-write consistency automatically for all operations:

  • After a successful PUT (new object or overwrite) or DELETE, any immediate GET or LIST sees the latest state.
  • There is no extra configuration or cost for this guarantee.

2. Choosing the Right S3 Storage Class

Picking a storage class comes down to how often you read the data, how fast you need it back, and how long you keep it:

Storage Class Access Pattern Retrieval Time Key Caveat
S3 Standard Frequent (hot) access Milliseconds Highest per-GB storage price, no retrieval fee
S3 Standard-IA Infrequent access Milliseconds Per-GB retrieval fee + 30-day minimum storage duration
S3 Glacier Instant Retrieval Rare reads, instant needed Milliseconds Per-GB retrieval fee + 90-day minimum duration
S3 Glacier Flexible Retrieval Archive (minutes to hours) 1 min – 12 hours Must restore object before reading; 90-day minimum
S3 Glacier Deep Archive Long-term compliance (7–10 yrs) 12 – 48 hours Lowest storage cost; 180-day minimum duration
S3 Intelligent-Tiering Unknown or changing access Milliseconds (hot/cool) Small monitoring fee per object, no retrieval fees

3. Automating Cost Savings with Lifecycle Rules

Instead of running cron jobs to clean up or re-tier old objects, attach an S3 Lifecycle configuration to a bucket or prefix:

{
  "Rules": [
    {
      "ID": "age-out-raw-uploads",
      "Status": "Enabled",
      "Filter": { "Prefix": "raw/" },
      "Transitions": [
        { "Days": 30, "StorageClass": "STANDARD_IA" },
        { "Days": 180, "StorageClass": "GLACIER" }
      ],
      "Expiration": { "Days": 365 }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

The Hidden Cost Trap

Colder storage classes charge per-GB retrieval fees and enforce minimum storage durations (30, 90, or 180 days). If you transition tiny objects (< 128 KB) or short-lived files that get deleted after two weeks, transition and early-deletion fees can cost more than leaving them in S3 Standard.


Practice & Interactive Lesson

Top comments (2)

Collapse
 
osamamalik profile image
Osama Malik • • Edited

One lifecycle detail that surprises people is that Standard IA and One Zone IA bill a minimum object size of 128 KB, so transitioning lots of small objects can raise the bill instead of lowering it. Lifecycle rules also require objects to sit in S3 Standard for at least 30 days before a transition to Standard IA. It is also worth adding a rule to abort incomplete multipart uploads after a few days, because those hidden parts are billed and never show up in a normal object listing.

Collapse
 
bytepatterns profile image
BytePatterns •

Great point, Osama. That 128 KB minimum object charge on Standard-IA and aborting incomplete multipart uploads trip people up both in real AWS bills and on SAA-C03 cost optimization questions.