S3

Amazon S3 is a highly scalable, durable, and performant object storage service designed to store and retrieve any amount of data from anywhere on the web.

Cheat Sheet

Prime Use Case

Use S3 for storing unstructured data (blobs) like images, videos, logs, backups, and data lake foundations where high durability and horizontal scalability are prioritized over low-latency random access.

Critical Tradeoffs

  • High throughput vs. high per-request latency
  • Infinite scalability vs. lack of POSIX file system features (e.g., no atomic renames)
  • Cost-effective storage vs. high egress costs

Killer Senior Insight

S3 is fundamentally a massive distributed Key-Value store where the 'Key' is the object path and the 'Value' is the opaque binary blob; treating it like a traditional hierarchical filesystem is a common architectural mistake.

Recognition

Common Interview Phrases

Need to store 'unlimited' user-generated content
Requirement for 99.999999999% (11 nines) durability
Decoupling storage from compute for a data lake
Serving static assets for a global web application

Common Scenarios

  • Static asset hosting (images, CSS, JS) behind a CDN
  • Staging area for ETL pipelines and Big Data processing (Spark/Presto)
  • Long-term archival and compliance logging
  • Database backups and snapshots

Anti-patterns to Avoid

  • Using S3 as a database for high-frequency transactional updates
  • Storing millions of tiny files (< 128KB) which incurs high metadata and request overhead
  • Mounting S3 as a local drive for applications requiring low-latency random IO

The Problem

The Fundamental Issue

The 'Storage Wall': Traditional block or file storage cannot scale horizontally to petabytes without massive complexity in RAID management, hardware failures, and volume re-partitioning.

What breaks without it

Local disks fill up, requiring manual migration and downtime

Data loss due to single-node or rack failures

Inability to share data across multiple compute instances concurrently

Why alternatives fail

EBS (Block Storage) is tied to a single Availability Zone and instance

EFS (NFS) is significantly more expensive and has throughput scaling limits compared to S3

HDFS requires significant operational overhead to manage NameNodes and DataNodes

Mental Model

The Intuition

Think of S3 like a valet parking service. You give them your car (data) and they give you a ticket (URL/Key). You don't care where they park it or how they move it; you just know that when you present the ticket, you get your car back exactly as it was.

Key Mechanics

1

Buckets: Logical containers for objects with unique global namespaces

2

Prefix Partitioning: S3 scales throughput by partitioning data based on the key prefix

3

Multipart Uploads: Breaking large files into chunks for parallel upload and fault tolerance

4

Strong Consistency: S3 now provides read-after-write consistency for all new objects and overwrites

Framework

When it's the best choice

  • Write-once, read-many (WORM) workloads
  • Storing large files (> 5MB) where throughput matters more than latency
  • Global distribution of data via integration with CloudFront

When to avoid

  • Applications requiring atomic directory renames (S3 simulates directories via keys)
  • Low-latency caching layers (use Redis instead)
  • Frequent small-byte range updates within a large object

Fast Heuristics

If data is unstructured and > 100GB
S3
If data requires POSIX compliance
EFS
If data requires sub-millisecond latency
EBS or Redis

Tradeoffs

+

Strengths

  • Virtually infinite capacity and throughput scaling
  • Extreme durability through cross-AZ replication
  • Tiered storage classes (Intelligent Tiering, Glacier) for cost optimization

Weaknesses

  • Higher First-Byte Latency (100-200ms) compared to local SSDs
  • No native support for appending data to existing objects
  • Complex security policies (IAM vs Bucket Policies vs ACLs)

Alternatives

EBS
Alternative

When it wins

When you need a boot volume or high-performance block storage for a database.

Key Difference

Block-level storage attached to a single EC2 instance.

EFS
Alternative

When it wins

When multiple EC2 instances need to share a common filesystem with standard file permissions.

Key Difference

Distributed file system supporting POSIX semantics.

Cassandra
Alternative

When it wins

When storing very small blobs with high update frequency and low latency requirements.

Key Difference

NoSQL database optimized for high-write availability.

Execution

Must-hit talking points

  • Mention 'Prefix-based partitioning' to show you understand how S3 scales internally
  • Discuss 'Lifecycle Policies' for moving data to Glacier to demonstrate cost-consciousness
  • Explain 'Multipart Uploads' for handling large files and network instability
  • Clarify that S3 is now 'Strongly Consistent', a major change from its historical eventual consistency

Anticipate follow-ups

  • Q:How would you secure sensitive data in S3? (Encryption at rest/transit, OAI for CloudFront)
  • Q:How do you handle the 'Hot Partition' problem in S3? (Randomizing prefixes or using hashes)
  • Q:How would you implement a cross-region disaster recovery plan using S3? (Cross-Region Replication)

Red Flags

Assuming 'ListObjects' is a fast operation.

Why it fails: Listing millions of objects is slow and expensive; it's better to maintain a separate metadata index in DynamoDB if frequent searching is required.

Using sequential IDs or timestamps as the start of S3 keys.

Why it fails: This creates hotspots on specific S3 partitions, though S3's modern automated scaling has mitigated this, it is still a sub-optimal design for extreme scale.