Stop 06 · Storage: S3, EBS & EFSTopics · 9/10

Amazon EFS Shared File Storage

Part of the AWS Roadmap

In short

Five web servers all need to read the same uploaded files. Block disks can't be shared like that, and object storage isn't a normal folder. File storage is the shared drive for servers.

Amazon EFS is a managed NFS file system that many Linux instances can mount at the same time across Availability Zones, and it grows and shrinks automatically. Use it when several servers need the same files, unlike EBS (one instance) or S3 (objects over HTTPS).

The blob character places a file on a big shared shelf in a staff room.

Think of it like this

The staff room shelf

Every teacher in the department uses the same staff room shelf. One teacher drops a question paper there and another picks it up a minute later. Nobody carries their own copy. A network file system is that shared shelf for your servers.

Watch it happen

Two servers, one folder

web-1
EFS (NFS)
web-2

mount /mnt/shared

1/5web-1 mounts the file system over NFS, like plugging into a shared network drive.

The big ideas

What you need to know

Shared by many

Many VMs, containers or functions can mount the same file system at once and see the same files.

Real folders

It's a normal POSIX file system with directories, permissions and file locks. Old apps work without changes.

Elastic size

EFS grows as you add files. You pay for what's stored, not for a fixed disk size.

Costs more per GB

File storage is pricier than object storage. Use it when apps truly need a shared filesystem, not for cheap bulk data.

See it in code

Walk through the code

bash
1# On Amazon Linux: install the EFS mount helper2sudo dnf install -y amazon-efs-utils3sudo mkdir -p /mnt/shared4 5# Mount with encryption in transit6sudo mount -t efs -o tls fs-0123456789abcdef0:/ /mnt/shared7df -h /mnt/shared8 9echo "hello from $(hostname)" | sudo tee /mnt/shared/hi.txt

1/3Install the helper and create a mount point.

Run the same mount on a second instance and you'll see hi.txt there too. The security group must allow NFS (port 2049) between them.

Save yourself the pain

Common mistakes

Oops

Using EFS to store terabytes of old logs.

Do this instead

That's object storage's job. Keep file storage for data that apps must open as files from several servers.

Oops

Forgetting the security group for port 2049.

Do this instead

The mount hangs if NFS traffic is blocked. Allow 2049 from your instances' security group to the EFS mount targets.

Your mission

Share a folder between two VMs

~40 min

Quick check

Four containers on different servers must read and write the same set of files as a normal folder. Which storage fits?

Go deeper

  1. 1Mount one EFS file system on two EC2 instances and share a file between them.
  2. 2Make a comparison table of EBS, EFS and S3 covering access method, sharing and typical use.
  3. 3Read about EFS storage classes and lifecycle management to cut cost.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge