AWS fundamentals path · Storage and databases · Topic 11 of 18

Block and file storage: EBS and EFS

Not started

Not everything fits in an object store. A database wants a block device it can fsync; a legacy app wants a directory it can share. AWS has three answers. **EBS** (Elastic Block Store) gives an instance a network-attached disk in one zone. **EFS** (Elastic File System) gives many machines a shared NFS file system that spans zones. **Instance store** is fast local disk on the physical host that disappears with the instance.

Why it matters: Databases, build caches and shared uploads need a file system, not an object store. Choosing a disk that lives in one zone or a file system that spans several decides what survives a zone failure.

  1. 1EBS is a network disk in one zone

    An EBS volume attaches to an instance in the same Availability Zone and behaves like a local block device.

  2. 2Snapshots are your way out

    EBS snapshots are incremental copies stored regionally. They are how you back up, copy volumes across zones and Regions, and recover.

  3. 3EFS is shared NFS

    EFS is an elastic NFSv4 file system that many instances, containers and functions mount at once, across zones.

  4. 4Pick by access pattern

    One writer needing low latency: EBS. Many readers and writers sharing files: EFS. Whole objects over HTTP: S3.

1

How it works

The explanation, with examples you can run.

EBS: a disk with a zone

An EBS volume is created in one Availability Zone, replicated across several servers inside it, and attached to instances in that zone (one at a time, except io1 and io2 multi-attach for clustered software). Volume types trade cost for performance:

TypeNotes
gp3General purpose SSD; baseline IOPS and throughput you can raise independently of size. The default choice.
io2 Block ExpressProvisioned IOPS for demanding databases, higher durability
st1, sc1Throughput-oriented and cold HDD for large sequential workloads

Because a volume lives in one zone, so does whatever depends on it. If that zone fails, the volume is unavailable until it recovers. Snapshots are the escape hatch: incremental, point-in-time copies stored at Region level, which you can restore into any zone, copy to another Region or account, and schedule with Data Lifecycle Manager or AWS Backup. A snapshot of a running database is crash-consistent at best; use the database's own backup or flush before snapshotting.

Encrypt volumes (you can make encryption the default per Region in account settings), and watch the throughput limits of both the volume and the instance type, since either can be the bottleneck.

EFS: shared and elastic

EFS speaks NFSv4.1 and grows and shrinks as you add files, so there is nothing to size. Many EC2 instances, ECS and EKS tasks, and Lambda functions can mount it at once. Regional file systems (the recommended kind) store data redundantly across several zones, with a mount target in each zone; One Zone file systems are cheaper and live in one zone. Throughput modes include Elastic, which scales with demand and bills per use.

The costs of sharing: every operation is a network round trip, so workloads with many small files and metadata calls (such as npm install or a Git checkout) are much slower than on a local disk, and NFS locking semantics are weaker than a local file system's. Lifecycle management can move cold files to cheaper Infrequent Access and Archive classes.

Choosing

  • Single writer, low latency, a database or a boot disk: EBS.
  • Many clients sharing files across zones: EFS.
  • Whole objects, HTTP access, unlimited scale, cheapest per GB: S3.
  • Scratch space and caches that may vanish: instance store.

Whatever you choose, the safest design keeps durable state in a managed service (S3, RDS, DynamoDB) and treats instances and their disks as replaceable.

2

Check yourself

3 questions. Get them all right to finish this topic.

  1. 1.An EC2 instance in zone a fails and the Auto Scaling group launches a replacement in zone b. Can it attach the old EBS volume?
  2. 2.Ten ECS tasks across three zones need to read and write the same directory of uploaded files. Which fits?
  3. 3.What happens to data on an instance store volume when the instance is stopped?

0 of 3 right so far. Get all three to finish this topic.