Skip to content
Tutorials Center
My learning

Topics

Lesson 12 of 70 ยท Compute with EC2

EFS and FSx File Systems

Learn Amazon EFS and FSx: throughput modes, storage classes and lifecycle, mounting on EC2, access points, and how to choose between EFS, EBS, S3 and FSx.

An EBS volume is a disk that belongs to one instance, and S3 stores objects that you reach through an API. Sometimes you need something in between: a normal folder, with normal paths and file permissions, that many servers can read and write at the same time. Think of a shared uploads directory behind a fleet of web servers, home folders for a team, or a render farm that reads the same project files.

AWS answers with managed file systems. Amazon EFS is the simple, elastic one for Linux. Amazon FSx is a family of four file systems that you choose when you need a specific technology, such as Windows file shares or a high-performance computing file system. This lesson explains how each works and how to choose between them and the other storage services.

File systems cannot run on this site, so the commands are read-only examples of real AWS CLI and Linux usage. The Python examples are stand-ins: a lifecycle simulator that uses invented prices, and a chooser that encodes this lesson's decision rules. They teach the logic, not real billing.

How EFS works

EFS is a managed NFS (Network File System) service. You create a file system, and AWS gives it an ID such as fs-0abc1234. There is no size to pick: it grows and shrinks as you add and delete files, and you pay for the gigabytes you actually store.

To reach the file system from a VPC, you create a mount target in each Availability Zone you use. A mount target is a network interface with an IP address inside one of your subnets. Instances mount the file system through the mount target in their own zone, so traffic stays inside the zone. Mount targets are guarded by a security group: it must allow inbound TCP port 2049 (NFS) from the instances' security group.

flowchart LR
    subgraph AZ1["Availability Zone a"]
        I1["EC2 instance"] --> M1["Mount target"]
    end
    subgraph AZ2["Availability Zone b"]
        I2["EC2 instance"] --> M2["Mount target"]
        C2["ECS task"] --> M2
    end
    M1 --> FS[("EFS file system<br/>stored across zones")]
    M2 --> FS

Many clients in several zones share one file system. Data is stored redundantly across zones.

Key facts:

  • Many clients at once. Thousands of EC2 instances, containers and even Lambda functions can mount the same file system.
  • Regional by default. Data is stored across several Availability Zones, so losing one zone does not lose the files. A One Zone option stores data in a single zone for a lower price.
  • POSIX semantics. Files have owners, groups and permissions as on any Linux disk, and locking works the way applications expect.
  • Linux only. EFS speaks NFS v4. Windows servers should use FSx for Windows File Server instead.
  • Encryption. Data can be encrypted at rest with KMS, and in transit with TLS when you mount with the right helper.

Mounting EFS on an instance

The easiest way is the amazon-efs-utils package, which adds a mount -t efs type that handles TLS and finds the right mount target for you. These are real commands, shown read-only:

Terminal
# Install the helper (Amazon Linux)
sudo dnf install -y amazon-efs-utils

# Create the mount point and mount with encryption in transit
sudo mkdir -p /mnt/shared
sudo mount -t efs -o tls fs-0abc1234:/ /mnt/shared

# Make it permanent: one line in /etc/fstab
# fs-0abc1234:/ /mnt/shared efs _netdev,tls 0 0

The _netdev option tells the system to wait for the network before mounting. Without it, a reboot can hang while the instance tries to mount a file system it cannot reach yet.

Creating the file system with the CLI looks like this (also read-only):

Terminal
aws efs create-file-system \
  --performance-mode generalPurpose \
  --throughput-mode elastic \
  --encrypted \
  --tags Key=Name,Value=shared-uploads

aws efs create-mount-target \
  --file-system-id fs-0abc1234 \
  --subnet-id subnet-0aaa1111 \
  --security-groups sg-0efs0001

Performance and throughput modes

Two settings decide how EFS performs.

Performance mode is chosen when you create the file system and cannot be changed afterwards:

  • General Purpose is the default and the right choice for almost everything. It has the lowest latency per operation.
  • Max I/O was designed for massively parallel workloads and trades a little latency for higher aggregate operations. It is an older option that new designs rarely need, and it is not offered with the newer Elastic throughput mode.

Throughput mode controls how fast data moves, and you can change it later:

  • Elastic (the recommended default) scales throughput up and down automatically with your workload and bills for the data you actually transfer. It suits spiky or unpredictable traffic.
  • Provisioned lets you set a throughput figure yourself, independent of how much data is stored. It fits a steady workload that needs more throughput than its size would otherwise allow.
  • Bursting ties throughput to the amount of data stored and lets you burst above that using credits. It is the older model, and it can be a problem for a small file system that suddenly needs speed.

If you cannot decide, pick General Purpose with Elastic throughput and measure.

Storage classes and lifecycle management

Not every file is used every day, so EFS has cheaper classes for cold data:

Class For Notes
Standard Frequently used files Stored across several zones
Infrequent Access (IA) Files read rarely Lower storage price, plus a per-GB fee when you read
Archive Files read a few times a year Lowest storage price, higher access fee
One Zone and One Zone-IA Data that is easy to recreate Single-zone copies at a lower price

You do not move files by hand. A lifecycle policy says "move files that have not been accessed for N days to IA" (and optionally to Archive), and a second setting says "move a file back to Standard the first time it is read". The file name and path never change, so applications do not notice anything.

This simulator applies such a policy to a small file list. The prices are invented round numbers per GB per month, and the access fee is ignored to keep the idea clear.

Python An EFS lifecycle policy simulator

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Most of the bytes here are cold, so the lifecycle policy removes most of the bill. The trade-off is that reading a cold file costs a small per-GB fee, so you tier data you expect to leave alone.

Access points

Mounting / gives a client the entire file system. An access point is an entry point that forces a particular identity and starting folder. For example, an access point for the uploads application can say "everyone who connects through me acts as user ID 1001 and sees only /apps/uploads as the root". A Lambda function or a container can then mount that access point and never see the other teams' folders. Access points work together with IAM policies, so you can also allow a role to use one access point only.

Amazon FSx: four file systems

EFS covers Linux and NFS. FSx is a family of fully managed file systems built on well-known technologies, for cases where you need the exact behavior of the original:

  • FSx for Windows File Server offers SMB shares with Active Directory integration, NTFS permissions and DFS. Choose it to move a Windows file server to AWS.
  • FSx for Lustre is a high-performance parallel file system for machine learning, simulations and media processing. It can link to an S3 bucket, loading data lazily and writing results back.
  • FSx for NetApp ONTAP serves NFS, SMB and iSCSI from one system, with snapshots, cloning and replication. It suits teams already running NetApp storage.
  • FSx for OpenZFS provides NFS with ZFS features such as instant snapshots and clones, for Linux workloads that need them.

Like EFS, FSx runs in your VPC and is reached through network interfaces. Unlike EFS, you usually pick a capacity (and throughput) when you create it, and you pay for what you provision.

EFS, EBS, S3 and FSx: choosing

Need Choose
A fast boot disk or database disk for one instance EBS
A shared Linux folder for many instances or containers, no capacity planning EFS
A Windows file share with Active Directory FSx for Windows File Server
Very fast shared scratch space for HPC or ML FSx for Lustre
Huge amounts of objects accessed over HTTP, cheapest per GB S3
A multi-protocol NetApp-style system FSx for NetApp ONTAP

The second stand-in turns these rules into code. Change the requirements and watch the answer change.

Python A storage chooser

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Good habits

  • Create one mount target per zone you use, and put clients in the same zone as the target they mount through.
  • Use the tls mount option and encryption at rest unless you have a measured reason not to.
  • Turn on lifecycle management for any file system that holds old data, and turn on backups (AWS Backup) for the rest.
  • Do not use EFS as a database disk. Database engines expect the low latency of EBS.
  • Watch the cost of Provisioned throughput: you pay for the setting whether or not you use it.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which port must a security group allow so instances can mount an EFS file system?

    EFS uses NFS, which runs on TCP port 2049. The mount target's security group must allow it from the clients.
  2. 2. Which statement about EFS performance and throughput settings is correct?

    Performance mode is fixed when the file system is created, while throughput mode can be changed later. Elastic is the recommended default, and General Purpose is the right performance mode for nearly everything.
  3. 3. What does an EFS lifecycle policy do?

    Lifecycle management transitions cold files to IA or Archive, keeping the same paths. Nothing is deleted.
  4. 4. A company moves its Windows file servers to AWS and uses Active Directory. Which service fits best?

    EFS is Linux-only (NFS). FSx for Windows File Server provides SMB shares with Active Directory integration.
  5. 5. What is an EFS access point for?

    An access point acts as an application-specific entry that forces a POSIX identity and a starting directory, so each application sees only its own folder.

Summary

  • EFS is an elastic, managed NFS file system for Linux that many instances, containers and functions can mount at once, through one mount target per zone and TCP port 2049.
  • Use General Purpose with Elastic throughput unless you have measurements that say otherwise. Performance mode cannot be changed later.
  • Lifecycle policies move cold files to IA and Archive automatically and can cut the bill sharply.
  • Access points give each application its own identity and root directory.
  • FSx offers Windows, Lustre, NetApp ONTAP and OpenZFS file systems for workloads that need those exact technologies.
  • Pick EBS for single-instance disks, EFS for shared Linux folders and S3 for objects.

Next: On-Demand, Reserved, Savings Plans and Spot