Back to Library
aws

S3 - Simple Storage Service

S3 is object storage with 11 nines of durability. It stores any file as a key-value pair inside a bucket, accessible via HTTP.

awsstorages3object-storage

What is AWS S3 (Simple Storage Service)?

S3 (Simple Storage Service) is AWS's object storage. Unlike a file system, S3 stores objects (files) as flat key-value pairs inside named containers called buckets. Each object has a key (path-like string), the data (up to 5 TB), and metadata.

S3 guarantees 99.999999999% (11 nines) durability - it replicates data across >=3 AZs in a region automatically.

Core Concepts

  • Bucket: global namespace container. Bucket names are globally unique across all AWS accounts.
  • Key: full path string - e.g., images/users/avatar_123.png. There are no real directories; the / is just part of the key name.
  • Object: the stored data + metadata. Max size 5 TB; multipart upload required for objects >5 GB.
  • Versioning: optionally store all versions of an object. Protects against accidental deletion.

Storage Classes

ClassUse ForRetrievalCost
StandardFrequently accessedMillisecondsHighest
Intelligent-TieringUnknown access patternsMillisecondsAuto-tiers
Standard-IAInfrequent accessMillisecondsLower storage, retrieval fee
One Zone-IANon-critical infrequentMillisecondsCheapest IA, single AZ
Glacier InstantArchives accessed sometimesMillisecondsVery low
Glacier FlexibleLong-term archiveMinutes to hoursLow
Glacier Deep Archive7+ year compliance12 hoursLowest

Use Lifecycle policies to automatically transition objects between classes (e.g., Standard -> Standard-IA after 30 days -> Glacier after 90 days -> delete after 365 days).

Access Control

  • Block Public Access: account or bucket level switch - blocks all public ACLs and bucket policies. On by default.
  • Bucket policy: JSON IAM policy attached to bucket. Controls cross-account access, conditions.
  • ACLs: legacy per-object ACLs. Avoid in new designs - use bucket policies instead.
  • Pre-signed URLs: time-limited signed URL granting temporary access to a specific object. Use to let users upload/download without exposing credentials.

S3 as a Static Host

Enable static website hosting on a bucket to serve index.html and error.html directly over HTTP. Combine with CloudFront for HTTPS, custom domain, and CDN caching.

Event Notifications

S3 can trigger events on object create/delete -> destinations: Lambda, SQS, SNS, EventBridge. Common pattern: upload image -> S3 event -> Lambda -> resize + store thumbnail.

S3 Select and Athena

  • S3 Select: run simple SQL on CSV/JSON/Parquet objects directly in S3, returning only matching rows. Reduces data transfer.
  • Athena: serverless query engine that runs SQL over S3 data using Glue Data Catalog schema. Pay per query. Used for log analytics, ad-hoc data exploration.

Consistency Model

As of 2020, S3 provides strong read-after-write consistency for all operations (PUT, DELETE). After a successful write, all reads return the new data immediately. Previously eventually consistent - this change eliminated a whole class of S3 bugs.

Multipart Upload

For large files (required >5 GB, recommended >100 MB):

  1. Initiate multipart upload -> get upload ID
  2. Upload parts (minimum 5 MB each, up to 10,000 parts)
  3. Complete upload -> S3 assembles the final object

Failed parts can be retried independently.

Interview Angle

S3 questions focus on: choosing the right storage class + lifecycle policies for cost, security (pre-signed URLs, bucket policies, block public access), and event-driven patterns (S3 -> Lambda pipelines). Also know the strong consistency model change in 2020. For large-scale analytics, mention Athena + Parquet for columnar queries.

Recommended Resources