After learning EC2, EBS, and Load Balancers, the next big challenge is handling files like images, uploads, and static content. At first, it might seem like everything can be stored on the server itself, but in real systems that approach quickly breaks.
This is where AWS provides two powerful solutions: EFS (Elastic File System) and S3 (Simple Storage Service).
The Problem: Multiple Servers, One Data Source
User → Load Balancer → web-01
→ web-02
If a user uploads a file to one server, another server may not have that file. This creates inconsistency in a load-balanced setup.
Solution 1: Using EFS (Shared File System)
EFS allows multiple EC2 instances to access the same file system at the same time. It behaves like a shared disk that is mounted on each server.
EC2-1 ─┐
├── EFS (shared folder)
EC2-2 ─┘
How EFS Works (Steps)
- Create EFS file system
- Attach security group (NFS port 2049)
- Install EFS client on EC2
- Mount EFS to a directory
- Use it like a shared folder
mount -t efs fs-xxxx:/ /mnt/efs
Once mounted, all EC2 instances see the same files.
Where EFS is Used
- Shared uploads
- WordPress media storage
- Legacy applications
Limitations of EFS
- More expensive
- Slower than local disk
- Requires mounting
Solution 2: Using S3 (Object Storage)
S3 works completely differently. Instead of mounting storage, files are accessed using URLs.
https://my-bucket.s3.amazonaws.com/image.jpg
Applications upload files to S3 and then access them directly via HTTP.
How S3 Works (Steps)
- Create a bucket
- Upload files
- Set permissions (optional public access)
- Access files via URL
Where S3 is Used
- Images and media
- Static website hosting
- Backups and logs
- Large-scale storage
EFS vs S3 (Key Differences)
EFS → File system (mounted)
S3 → Object storage (URL-based)
- EFS is used inside EC2
- S3 is accessed over the internet
- EFS is shared storage
- S3 is global storage
Real Architecture Comparison
Using EFS
User → ALB → EC2 → EFS
Using S3 (Modern)
User → S3 (direct)
User → EC2 (logic only)
Best Practice Architecture
User
↓
ALB
↓
EC2 (application)
↓
S3 (images/files)
In modern systems, EC2 handles logic, while S3 handles file storage.
When to Use What
- Use EFS → when app needs shared file system
- Use S3 → for images, videos, and static content
What I Learned
- Not all storage is the same in cloud
- EFS solves shared filesystem problems
- S3 solves scalability and performance issues
- Modern apps prefer S3 over EFS
Final Thoughts
This lesson helped me understand one of the most important decisions in cloud architecture: how to store and serve data efficiently. Choosing between EFS and S3 is not just a technical choice — it directly impacts performance, cost, and scalability.
← Back to Blogs