Skip to main content

Amazon EFS - Shared File Storage for Multiple Servers

Mount Amazon EFS as a shared file system across multiple EC2 instances and ECS Fargate tasks with automatic scaling, lifecycle tiers, and multi-AZ availability.

What you will learn

  • Why shared file storage exists and what problem EBS cannot solve
  • EFS vs EBS vs Instance Store — the three storage types and when each is correct
  • EFS performance modes — General Purpose vs Max I/O
  • EFS throughput modes — Bursting, Provisioned, and Elastic (the recommended default)
  • EFS storage tiers — Standard and Infrequent Access with lifecycle policies
  • How EFS works across Availability Zones using Mount Targets
  • Connecting EC2 instances and ECS Fargate tasks to EFS
  • EFS security — Security Groups and IAM-based access policies
  • EFS vs FSx — when to use which

Why this matters

At Hotstar, a video transcoding pipeline runs across 20 EC2 instances in parallel. Each instance reads the same source video file and writes output segments to a shared location. If each instance has its own EBS volume, none of them can see the other's output. EFS mounts as a shared filesystem — all 20 instances read and write to the same directory as if they were one machine. At Swiggy, configuration files and shared assets that all application servers need are stored in EFS. Add a new server — it mounts the same filesystem and immediately has access to all shared files. No S3 API calls, no syncing, just a regular filesystem.

EBS vs EFS vs Instance Store — The Three Storage Types

Understanding when to use each comes down to one question: how many servers need access at the same time?

TEXT
EBS (Elastic Block Store):
Attached to ONE EC2 instance at a time (except io1/io2 Multi-Attach)
Like an external hard drive — plugged into one computer
Data persists when instance stops
AZ-specific — cannot cross availability zones
Use for: OS disk, database storage, single-server application data
EFS (Elastic File System):
Mounted by MANY EC2 instances simultaneously
Like a network drive — many computers access the same folder
Data persists forever — independent of any instance
Multi-AZ — same filesystem available across all AZs in a region
Use for: shared content, ML training data, CMS media, config files
Instance Store:
Physically attached to the host hardware
Lost permanently when instance stops or terminates
Fastest possible IOPS — no network involved
Use for: temporary data, caches, scratch space
Remember

EFS is the only AWS storage that multiple EC2 instances can mount simultaneously as a filesystem. If your application needs files shared across multiple servers, the answer is always EFS — not S3 (which is object storage accessed via API, not mountable as a filesystem).

How EFS Works — Mount Targets

EFS creates a Mount Target in each Availability Zone. Each Mount Target gets an IP address inside your VPC. EC2 instances connect to the Mount Target in their AZ.

◈ DIAGRAM
EFS File System (regional — one filesystem)
├── Mount Target in ap-south-1a → IP: 10.0.1.50
├── Mount Target in ap-south-1b → IP: 10.0.2.50
└── Mount Target in ap-south-1c → IP: 10.0.3.50
EC2 in ap-south-1a mounts via 10.0.1.50
EC2 in ap-south-1b mounts via 10.0.2.50
EC2 in ap-south-1c mounts via 10.0.3.50
All three EC2 instances see the SAME files.
Write on EC2-A → EC2-B and EC2-C see it immediately.

EFS replicates data across multiple AZs automatically. The filesystem survives a full AZ failure.

Performance Modes

General Purpose (default — use this for everything):

TEXT
Lower latency per operation
Suitable for: web serving, content management, home directories, most workloads
Limit: 35,000 IOPS maximum

Max I/O:

TEXT
Higher aggregate throughput and IOPS
Slightly higher latency per operation
Suitable for: big data, media processing, scientific workloads with thousands of instances
Use only when General Purpose hits its 35,000 IOPS ceiling
Remember

Start with General Purpose. Switch to Max I/O only if you see IOPS being throttled at scale. For most workloads including production web applications, General Purpose is the right choice.

Throughput Modes

Bursting (old default):

TEXT
Throughput scales with filesystem size
Small filesystem = low throughput baseline
Credit system for bursts above baseline
Problem: if filesystem is small, baseline throughput is very low

Provisioned:

TEXT
You specify throughput independently of filesystem size
Pay for provisioned throughput whether you use it or not
Use when: your filesystem is small but you need high consistent throughput

Elastic (recommended default):

TEXT
Automatically scales throughput up and down based on workload
No capacity planning needed
Pay only for what you use
AWS recommends this for most new workloads
Tip

Always use Elastic throughput mode for new EFS file systems unless you have a specific reason not to. It handles unpredictable workloads automatically, costs nothing when idle, and removes the complexity of sizing throughput in advance.

EFS Storage Tiers and Lifecycle

Like S3, EFS has tiers for hot and cold data. Files automatically move between tiers based on access patterns.

TEXT
EFS Standard:
For actively accessed files
Higher cost per GB
Sub-millisecond latency
EFS Infrequent Access (EFS-IA):
For files not accessed recently
Up to 92% cheaper per GB
Small retrieval fee when accessed

Lifecycle Policy:

TEXT
Set a rule: move files not accessed in 30 days to EFS-IA
Files you access regularly stay in Standard automatically
Files you stop touching move to IA automatically
EFS Intelligent Tiering: automatic movement between Standard and IA
Similar to S3 Intelligent-Tiering — no manual management needed

This means you pay Standard prices only for files you actually use. Everything else is automatically cheaper.

EFS Security

Network access — Security Groups:

TEXT
EC2 Security Group must allow: outbound NFS port 2049 to EFS Mount Target
EFS Mount Target Security Group must allow: inbound NFS port 2049 from EC2 Security Group

Data access — IAM and EFS Access Points:

◈ DIAGRAM
EFS Access Points enforce a specific POSIX user and directory per client
Each application or team gets its own Access Point
App A's Access Point → /app-a directory (cannot see /app-b)
App B's Access Point → /app-b directory (cannot see /app-a)

Encryption:

TEXT
At rest: enabled during filesystem creation using KMS
In transit: TLS via amazon-efs-utils mount helper
Cannot enable at-rest encryption after creation — must create new filesystem

EFS vs FSx — When to Use Which

EFS is Linux-only NFS. For other filesystems you need FSx.

EFS FSx for Windows FSx for Lustre
Protocol NFS SMB (Windows) Lustre (HPC)
OS Linux only Windows Linux
Use for Shared Linux files Windows file shares, Active Directory HPC, ML, high-speed scratch
Multi-AZ Yes Yes Single-AZ or Multi-AZ

If your servers are Windows → FSx for Windows File Server If your workload is HPC or ML training → FSx for Lustre If your servers are Linux and need shared files → EFS

Hands-on Lab — Mount EFS on Two EC2 Instances

Step 1 — Create an EFS Security Group

◈ DIAGRAM
EC2 → Security Groups → Create security group
Name: efs-sg VPC: your VPC
Inbound rule: NFS (port 2049) from your EC2 security group
Create security group

Step 2 — Create the EFS File System

◈ DIAGRAM
EFS → Create file system
Name: devops-shared-fs
VPC: your VPC
Click Customize:
Performance mode: General Purpose
Throughput mode: Elastic
Lifecycle: 30 days since last access → EFS-IA
Encryption: Enable
Next
Mount targets:
ap-south-1a → select private subnet → security group: efs-sg
ap-south-1b → select private subnet → security group: efs-sg
Next → Create
Wait for State: Available

Step 3 — Mount on EC2 Instance 1

TEXT
Copy the EFS filesystem ID (fs-xxxxxxxx)
SSH into EC2 Instance 1:
Bash
## Install EFS mount helper
sudo yum install -y amazon-efs-utils
## Create mount point
sudo mkdir /shared
## Mount the EFS filesystem
sudo mount -t efs -o tls fs-xxxxxxxx:/ /shared
## Write a file
echo "Written by EC2 Instance 1" | sudo tee /shared/test.txt
## Verify
cat /shared/test.txt

Step 4 — Mount on EC2 Instance 2 and verify sharing

TEXT
SSH into EC2 Instance 2 (different instance, same VPC):
Bash
sudo yum install -y amazon-efs-utils
sudo mkdir /shared
sudo mount -t efs -o tls fs-xxxxxxxx:/ /shared
## Read the file written by Instance 1
cat /shared/test.txt
## Shows: Written by EC2 Instance 1
## Write from Instance 2
echo "Written by EC2 Instance 2" | sudo tee /shared/test2.txt
TEXT
Back on Instance 1:
Bash
ls /shared/
## Shows both test.txt and test2.txt — real-time sharing confirmed

Step 5 — Make mount persistent across reboots

Bash
## Add to /etc/fstab so it mounts automatically on reboot
echo "fs-xxxxxxxx:/ /shared efs _netdev,tls 0 0" | sudo tee -a /etc/fstab

Step 6 — Cleanup

Bash
Unmount on both instances: sudo umount /shared
EFS → File systems → devops-shared-fs → Delete
EC2 → Security Groups → efs-sg → Delete

Common Mistakes to Avoid

Common Mistake

Trying to use S3 as a shared filesystem between EC2 instances. S3 is object storage accessed via HTTP API — it cannot be mounted as a filesystem with standard Linux tools. For shared filesystem access across multiple instances the answer is EFS, not S3.

Common Mistake

Forgetting to open NFS port 2049 in the EFS Security Group. The most common reason EFS mounts fail is a missing inbound rule on port 2049. Always check Security Group rules first when debugging mount failures.

Common Mistake

Enabling at-rest encryption after creation. EFS encryption at rest can only be enabled when the filesystem is created. If you forget, you must create a new encrypted filesystem, copy the data, and switch over. Enable it at creation time — always.

Tip

Use EFS with ECS Fargate for persistent storage in containers. EBS cannot attach to Fargate tasks. EFS can. Any Fargate task that needs to read or write persistent files — ML models, configuration, uploads — should mount EFS. The same filesystem can be mounted by hundreds of Fargate tasks simultaneously.

Resources

AWS Direct Connect vs Site-to-Site VPN Failover

AWS Direct Connect vs Site-to-Site VPN Failover

Direct Connect vs VPN isn't really either/or for production — it's a primary-plus-failover pattern. Here's how to design it, and when either/or is right.

5 min read•Aug 2026
Lambda vs Fargate vs EC2 Spot: The Cost Crossover

Lambda vs Fargate vs EC2 Spot: The Cost Crossover

Lambda vs Fargate vs EC2 Spot, at the crossover where Lambda stops being cheaper — 2026 pricing, invocation thresholds, and interruption math.

5 min read•Aug 2026
Secrets Manager vs Parameter Store vs Vault

Secrets Manager vs Parameter Store vs Vault

AWS Secrets Manager, Parameter Store, and HashiCorp Vault compared for 2026 - cost math, rotation, multi-cloud fit, and the Vault-to-OpenBao fork.

5 min read•Aug 2026
AWS VPC Security: Hardening Every Layer

AWS VPC Security: Hardening Every Layer

Most cloud security incidents start with a misconfigured VPC. Here's how to harden every layer — subnets, Security Groups, NACLs, and IAM — for production.

5 min read•Jul 2026
Event-Driven Architecture on AWS Explained

Event-Driven Architecture on AWS Explained

Event-driven architecture on AWS decouples services and absorbs traffic spikes using SQS, SNS, EventBridge, and Lambda — workflows that scale themselves.

5 min read•Jul 2026
S3 vs RDS vs DynamoDB: Choosing AWS Storage

S3 vs RDS vs DynamoDB: Choosing AWS Storage

Choosing S3, RDS, or DynamoDB wrong costs you in performance, cost, and scalability. Here is a practical decision guide based on your actual access patterns.

5 min read•Jul 2026
AWS Cost Optimisation: Cut Cloud Bills 40-60%

AWS Cost Optimisation: Cut Cloud Bills 40-60%

AWS bills surprise teams every month. Here are the 8 concrete actions that cut cloud spend by 40-60% without touching your application architecture.

5 min read•Jul 2026
EC2 vs Lambda vs Fargate: Choosing AWS Compute

EC2 vs Lambda vs Fargate: Choosing AWS Compute

EC2, Lambda, or Fargate — choosing the wrong AWS compute option costs you money and performance. Here is exactly when to use each one in production.

5 min read•Jul 2026

Explore More in AWS Storage and Databases

All 6 Topics

Frequently Asked Questions

Is Amazon EFS - Shared File Storage for Multiple Servers free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Amazon EFS - Shared File Storage for Multiple Servers topic cover?

Mount Amazon EFS as a shared file system across multiple EC2 instances and ECS Fargate tasks with automatic scaling, lifecycle tiers, and multi-AZ availability.