Difficulty: Intermediate
What is the difference between Amazon EBS and Amazon EFS, and when would you use each (or S3 instead)?
Amazon EBS is block storage: a virtual disk attached to a single EC2 instance in one Availability Zone, with low latency and the instance's own file system on top. Amazon EFS is a managed NFS file system: many EC2 instances, containers, and Lambda functions across multiple AZs can mount it at the same time, and it grows and shrinks automatically. Use EBS for boot volumes and databases on one machine, EFS when several compute nodes need to share the same files, and S3 when you just need to store and serve objects over HTTP.
| Aspect | EBS | EFS |
|---|---|---|
| Storage type | Block device (you format it: ext4, xfs, NTFS) | Managed file system over NFSv4 |
| Attachment | One instance (Multi-Attach only for io1/io2 within one AZ) | Thousands of clients concurrently |
| Scope | Single AZ | Regional (multi-AZ) or One Zone |
| Capacity | Provisioned size, you resize manually | Elastic, pay for what you store |
| Latency | Lowest (sub-millisecond on SSD) | Low milliseconds, higher than EBS |
| Operating systems | Linux and Windows | Linux (Windows shares use FSx for Windows) |
| Clients | EC2 | EC2, ECS, EKS, Lambda, on-premises via VPN or Direct Connect |
| Price per GB | Lower | Higher, reduced with Infrequent Access and Archive classes |
wp-content).EFS lifecycle management moves files not accessed for a set time into Infrequent Access or Archive storage classes, which cuts costs for data that is written once and rarely read.
S3 is object storage accessed through an API, not a mounted file system. It is cheaper still and effectively unlimited, and it is the right answer for user uploads, static assets, backups, and data lakes. If an application can talk to S3 directly, that is usually better than putting files on EFS. Use EFS when software expects a POSIX file system path and shared access.
# On each instance (Amazon Linux)
sudo dnf install -y amazon-efs-utils
sudo mkdir -p /mnt/shared
# Mount with TLS using the EFS mount helper
sudo mount -t efs -o tls fs-0123456789abcdef0:/ /mnt/shared
# Persist across reboots
echo "fs-0123456789abcdef0:/ /mnt/shared efs _netdev,tls 0 0" | sudo tee -a /etc/fstab
# A file written on instance A is immediately visible on instance B
echo "hello" | sudo tee /mnt/shared/test.txt
Both instances see the same files because they mount the same EFS file system; an EBS volume could only be attached to one of them.
Amazon EFS, Amazon EBS, Block vs File Storage, NFS, Multi-AZ Storage