Amazon EFS
A managed NFS file system that many Linux instances share across AZs, with performance and throughput modes, storage classes and lifecycle policies.
What it is
Amazon EFS (Elastic File System) is a managed network file system (NFS) that many EC2 instances mount at the same time, across several AZs. Every instance sees the same folders and files, and a file written on one is readable on the others straight away.
- Highly available and scalable: data is stored redundantly across AZs, and the file system grows and shrinks automatically, up to petabytes. No capacity planning.
- Pay per use: billing is for the GB actually stored (not provisioned), at a higher price per GB than EBS.
- Works with Linux instances, and with containers (ECS, EKS, Fargate) and Lambda. Not Windows.
Use cases: content management systems and WordPress (shared uploads), web serving, shared home directories, data sharing between apps, machine-learning training data.
How it works
- A file system is created in a Region. EFS creates a mount target (a network interface with an IP address) in a subnet of each chosen AZ.
- Instances in each AZ mount the file system through their local mount target, using the NFSv4.1 protocol on port 2049.
- A security group on the mount targets controls which instances may connect: allow inbound NFS (2049) from the instances' security group.
- All mount targets lead to the same data.
It's a POSIX file system with the standard Linux file API: permissions, owners, file locking. IAM policies can also control access, and access points give each application its own directory and user. Data can be encrypted at rest with KMS (chosen at creation) and in transit with TLS (using the EFS mount helper).
Performance settings
Performance mode (set at creation)
- General Purpose (default): lowest latency. Web servers, CMS, home directories. AWS recommends it for all file systems.
- Max I/O: higher latency but built for highly parallel work (big data, media processing). Now a previous-generation option.
Throughput mode
- Elastic (default, recommended): throughput scales up and down automatically with the workload; billing is for the data read and written. Best for spiky or unpredictable workloads. Up to tens of GiB/s of reads per file system.
- Provisioned: a throughput is set regardless of size, for example 1 GiB/s for a 1 TB file system. For steady, known needs.
- Bursting: throughput grows with the amount stored (about 50 MiB/s per TB, with bursts up to 100 MiB/s), using credits.
EFS scales to thousands of concurrent NFS clients.
Storage classes and lifecycle
EFS can move files that nobody reads to cheaper storage, using lifecycle policies:
- Standard: for frequently accessed files, with millisecond latency.
- Infrequent Access (IA): cheaper to store, but a fee is charged each time a file is read. For files used a few times a quarter.
- Archive: cheaper again, for files read a few times a year or less (up to about 50% cheaper than IA).
- By default, files not accessed for 30 days move to IA and after 90 days to Archive. Files can also move back to Standard on first access.
Together with the right file system type, AWS quotes savings of over 90% compared with keeping everything in Standard.
Availability and durability
- Regional file systems store data across multiple AZs: great for production. (The slides call this Standard.)
- One Zone file systems store data in one AZ: cheaper, great for development. Backups are on by default, and they work with the IA storage class (One Zone-IA).
Updated since the slides
AWS now calls the multi-AZ file system type Regional rather than Standard (Standard is now only the name of a storage class). Elastic is the default throughput mode, and Max I/O is marked as previous generation; AWS recommends General Purpose for every file system. Elastic throughput limits have grown well beyond the slide's 3 GiB/s reads.
Exam tips
- "Shared file system for many Linux instances across AZs", "WordPress / CMS shared content" → EFS.
- "POSIX-compliant shared storage", "NFS" → EFS.
- "Windows file share" → not EFS: FSx for Windows File Server.
- "Unpredictable or spiky throughput" → Elastic throughput. "Known, steady high throughput regardless of size" → Provisioned.
- "Reduce cost of rarely used files" → lifecycle policy to IA / Archive.
- "Cheapest, dev/test, single AZ is fine" → One Zone (with One Zone-IA).
- "Instances can't mount EFS" → check the mount target's security group allows NFS (2049).
Common traps
- "Mount EFS on Windows instances." Not supported.
- "EFS needs capacity planning." It grows and shrinks by itself; billing is for what's stored.
- "EFS is cheaper than EBS." Per GB it costs several times more; it's chosen for sharing, not price.
Hands-on lab: share files between two AZs
Goal: mount one EFS file system on instances in two AZs and share a file between them.
Costs money
EFS charges per GB stored (a few KB here, effectively free) and per GB read or written with Elastic throughput (tiny). Two t3.micro instances add about $0.04 an hour.
Launch two instances in different AZs
Launch saa-efs-a in a subnet in us-east-1a and saa-efs-b in us-east-1b, Amazon Linux 2023, t3.micro, tag Project=saa-lab. Give both the same new security group saa-efs-clients (SSH from your IP is enough).
Create the file system
Open Amazon EFS → Create file system, name saa-efs, default VPC, Regional. Then open it, Network → Manage, and for each mount target replace the default security group with a new group saa-efs-mt that allows NFS (2049) from saa-efs-clients.
Mount it on both instances
On each instance (EC2 Instance Connect):
sudo dnf install -y amazon-efs-utils
sudo mkdir /efs
sudo mount -t efs -o tls fs-XXXXXXXX:/ /efs # your file system ID(The file system's Attach button shows the exact command.)
Share a file
On saa-efs-a: echo "written in 1a" | sudo tee /efs/hello.txt. On saa-efs-b: cat /efs/hello.txt. The file written in one AZ appears in the other.
Expected result: two instances in different AZs reading and writing the same files.
Clean up: terminate both instances, delete the file system (type its ID to confirm), then delete the security groups saa-efs-mt and saa-efs-clients.