Level: Beginner to Intermediate
1. Introduction
In today’s cloud environment, applications often run across multiple EC2 instances. One common challenge is sharing files and application data between these servers.
Imagine you have three EC2 instances:
- EC2 Instance 1 – Ubuntu Linux
- EC2 Instance 2 – Red Hat Enterprise Linux
- EC2 Instance 3 – Amazon Linux 2
Each server needs access to the same files. If you store the files locally on each EC2 instance, you will have multiple copies of the same data.
This creates synchronization, administration, and storage management challenges.
Amazon Elastic File System (Amazon EFS) solves this problem by providing a shared, scalable file system that multiple Linux-based EC2 instances can access simultaneously.
2. What is Amazon EFS?
Amazon Elastic File System (EFS) is a fully managed, elastic file storage service provided by Amazon Web Services (AWS).
It allows multiple EC2 instances to access the same file system simultaneously.
Amazon EFS automatically grows and shrinks as files are added or removed. You do not need to manually provision storage capacity.
EFS uses the Network File System (NFS) protocol, primarily NFS version 4.1 for Linux workloads.
3. Why Do We Need Amazon EFS?
Consider a company running a web application on three EC2 instances.
All three servers need access to:
- Application files
- Shared documents
- Images and videos
- Reports
- Configuration files
- User-uploaded content
Without shared storage, administrators may need to copy files between servers manually.
This increases operational complexity.
With Amazon EFS, all three EC2 instances can access the same shared directory.
For example, when a file is created on EC2 Instance 1, the other instances can access that file through the same EFS file system, subject to file permissions.
4. Amazon EFS Architecture
A typical Amazon EFS architecture contains:
- Amazon VPC
- Multiple EC2 instances
- Amazon EFS file system
- EFS mount targets
- Security groups
- NFS communication over TCP port 2049
Example architecture:
EC2 Ubuntu ──┐
EC2 Red Hat ──┼── NFS (TCP 2049) ── Amazon EFS
EC2 Amazon Linux 2 ──┘
All three EC2 instances connect to the same EFS file system.
5. Important Features of Amazon EFS
A. Shared File Storage
Multiple EC2 instances can access the same file system simultaneously.
B. Automatic Scaling
EFS automatically adjusts storage capacity based on the amount of data stored.
C. High Availability
Regional EFS file systems store data redundantly across multiple Availability Zones.
D. Linux Compatibility
EFS supports Linux workloads using the NFS protocol.
E. Encryption
EFS supports encryption at rest and encryption in transit.
F. Backup
Amazon EFS integrates with AWS Backup to help protect your data.
G. Lifecycle Management
You can move infrequently accessed files to lower-cost storage classes using lifecycle policies.
6. Amazon EFS Storage Classes
Amazon EFS provides different storage classes for different access patterns.
| Storage class | Purpose |
|---|---|
| EFS Standard | Frequently accessed data |
| EFS Standard-IA | Infrequently accessed data |
| EFS Standard Archive | Long-term infrequently accessed data |
| EFS One Zone | Data stored in one Availability Zone |
| EFS One Zone-IA | Infrequently accessed data in one AZ |
| EFS One Zone Archive | Archive data in one AZ |
Choose the storage class based on your availability, access, and cost requirements.
7. EFS Performance and Throughput Modes
Amazon EFS provides different performance and throughput options.
Performance modes:
- General Purpose: Recommended for most workloads and offers lower per-operation latency.
- Max I/O: A previous-generation option for highly parallelized workloads that can tolerate higher latency.
Throughput modes:
- Elastic Throughput: Automatically adjusts throughput based on workload activity.
- Provisioned Throughput: Allows you to specify throughput independently of file system size.
- Bursting Throughput: Provides throughput based on stored data and accumulated burst credits.
For most new general-purpose deployments, General Purpose performance mode and Elastic Throughput are good starting points.
8. Real-World Example: Sharing EFS Across Three EC2 Instances
Let’s understand a practical implementation.
Scenario:
A company wants to configure shared storage across three EC2 instances running different Linux operating systems.
| EC2 instance | Operating system | Purpose |
|---|---|---|
| EC2-01 | Ubuntu | Application server |
| EC2-02 | Red Hat Linux | Application server |
| EC2-03 | Amazon Linux 2 | Application server |
Implementation approach:
- Create an Amazon EFS file system.
- Select the required VPC.
- Configure EFS mount targets in the required Availability Zones.
- Create a security group allowing inbound NFS traffic on TCP port 2049 from the EC2 security group.
- Install the required EFS client or NFS utilities on each EC2 instance.
- Mount the EFS file system on all three servers.
- Create a test directory and file from Ubuntu.
- Verify that the same file is accessible from Red Hat and Amazon Linux 2.
Expected result:
All three EC2 instances can access the same shared directory.
For example:
/shared-data/
If EC2-01 creates a file named test.txt, EC2-02 and EC2-03 can also access it through the mounted EFS file system.
9. Amazon EFS vs Amazon EBS vs Amazon S3
This is an important topic for AWS interviews and certification exams.
| Feature | Amazon EFS | Amazon EBS | Amazon S3 |
|---|---|---|---|
| Storage type | File storage | Block storage | Object storage |
| Access | Shared NFS access | Block device attached to EC2 | API-based object access |
| Multiple EC2 access | Yes | Depends on volume type and configuration | Yes, through APIs |
| Scaling | Elastic | Volume management required | Virtually unlimited |
| Common use | Shared Linux files | OS and application disks | Backups and objects |
When should you use each service?
- Use EFS when multiple Linux servers need shared file storage.
- Use EBS when an EC2 instance needs block storage for its operating system or applications.
- Use S3 when you need scalable object storage for backups, images, videos, and documents.
10. Amazon EFS Security Best Practices
Security is an important part of every AWS storage deployment.
Follow these recommendations:
- Use security groups to restrict NFS access.
- Allow TCP port 2049 only from authorized EC2 security groups.
- Enable encryption at rest.
- Use encryption in transit.
- Configure appropriate POSIX file permissions.
- Use EFS access points when application-specific access control is required.
- Enable AWS Backup where appropriate.
- Monitor EFS using Amazon CloudWatch.
- Avoid exposing EFS mount targets to unnecessary networks.
- Regularly review access permissions.
11. Common Amazon EFS Use Cases
Amazon EFS is useful in many real-world environments:
- Shared storage for web servers.
- Content management systems.
- Application file sharing.
- Container-based applications.
- Shared user home directories.
- Development and testing environments.
- Data sharing between Linux servers.
- Enterprise application storage.
12. Conclusion
Amazon EFS is a powerful AWS storage service that simplifies shared file storage across multiple compute instances.
It eliminates the need to manually synchronize files between servers and provides elastic storage capacity, managed infrastructure, and multi-AZ availability with Regional file systems.
For AWS administrators, cloud engineers, DevOps engineers, and system administrators, understanding EFS architecture and implementation is an important practical skill.
My recommendation: Create a small EFS lab with three EC2 instances running Ubuntu, Red Hat, and Amazon Linux 2. Mount the same file system on all three servers and test file sharing. This practical exercise will help you understand how shared storage works in a real AWS environment.