Block and File Storage: EBS and EFS

Choose between EBS volumes, instance store, EFS and FSx, and protect block storage with snapshots.

Intermediate · about 3 hours · difficulty 2/5

Learn first: EC2 Instances, AMIs and Pricing Options

Not everything fits in object storage. Databases and operating systems need block storage, and some apps need a shared file system.

Amazon EBS (block)

  • Network-attached disks for EC2, living in one AZ.
  • gp3 is the default general-purpose SSD: set size, IOPS and throughput independently, and it is cheaper than gp2.
  • io2 for high-performance databases; st1/sc1 HDD for throughput-heavy, cheap storage.
  • Snapshots are incremental backups stored in S3 behind the scenes. Copy them across regions for DR and use Data Lifecycle Manager or AWS Backup to automate them.
  • Volumes can be resized and changed type without downtime.

Amazon EFS (file)

  • A managed NFS file system that many instances, containers or Lambda functions can mount at once, across AZs.
  • Scales automatically; pay for what you store. Lifecycle management moves cold files to cheaper tiers.
  • Linux only. For Windows file shares use FSx for Windows File Server; for high-performance computing use FSx for Lustre.

Equivalents

Azure Managed Disks and Azure Files; Google Persistent Disk and Filestore.

Pitfalls

  • Assuming EBS survives an AZ failure. It does not; snapshots do.
  • Unattached EBS volumes and old snapshots quietly billing every month.
  • Using EFS as a database disk; latency is higher than EBS.

You are ready to move on when you can attach, format, mount and snapshot an EBS volume, and explain when EFS is the better fit.

Key concepts

  • EBS volume types (gp3, io2)
  • EBS snapshots
  • Data Lifecycle Manager
  • EBS encryption
  • Amazon EFS
  • FSx family
  • Block vs file vs object

Mini project

Attach a small extra gp3 volume to a free-tier instance, format it, mount it at /data, write a file, snapshot it, then restore the snapshot to a new volume in another AZ and read the file. Delete volumes and snapshots and terminate the instance afterwards so nothing keeps billing.

Check yourself

Three EC2 instances in different AZs need to read and write the same uploaded files. Would you use EBS, EFS or S3, and why?

Free resources