AWS EBS & EFS โ Block and File Storage
AWS EBS & EFS โ Block and File Storage
Section titled โAWS EBS & EFS โ Block and File StorageโBeyond S3 (object storage), AWS offers two types of persistent storage for EC2 workloads:
- EBS (Elastic Block Store) โ Block storage attached to a single EC2 instance (like a hard drive)
- EFS (Elastic File System) โ Shared NFS file system accessible by many instances simultaneously
EBS โ Elastic Block Store
Section titled โEBS โ Elastic Block StoreโEBS provides network-attached block storage for EC2 instances. Itโs the primary storage for the OS disk and application data.
In Azure terms: EBS = Azure Managed Disks
EBS Volume Types
Section titled โEBS Volume Typesโ| Type | Description | Use Case | Max IOPS |
|---|---|---|---|
| gp3 (General Purpose SSD) | Baseline 3,000 IOPS, configurable | Boot volumes, general workloads | 16,000 |
| gp2 (General Purpose SSD, older) | IOPS scales with size (3 IOPS/GB) | General workloads (prefer gp3) | 16,000 |
| io2 Block Express | High IOPS, 99.999% durability | Mission-critical databases | 256,000 |
| io1 (Provisioned IOPS SSD) | Consistent high IOPS | IOPS-intensive databases | 64,000 |
| st1 (Throughput Optimized HDD) | Low cost, sequential throughput | Big data, log processing | 500 MB/s |
| sc1 (Cold HDD) | Lowest cost | Infrequently accessed data | 250 MB/s |
gp3 is the recommended default โ better performance than gp2 at lower cost.
Key EBS Features
Section titled โKey EBS Featuresโ| Feature | Description |
|---|---|
| Single-AZ | EBS volumes are tied to a specific AZ |
| Snapshots | Point-in-time backups stored in S3 (incremental) |
| Encryption | AES-256 via KMS โ encrypt at creation |
| Multi-Attach | io1/io2 volumes can attach to up to 16 EC2 instances (same AZ) |
| Elastic Volumes | Resize, change type, or adjust IOPS without downtime |
EBS Snapshots
Section titled โEBS Snapshotsโ# Create a snapshotaws ec2 create-snapshot \ --volume-id vol-0abc123 \ --description "My backup snapshot"
# Copy snapshot to another regionaws ec2 copy-snapshot \ --source-region us-east-1 \ --source-snapshot-id snap-0abc123 \ --destination-region eu-west-1 \ --description "Cross-region backup"
# Create a volume from a snapshotaws ec2 create-volume \ --snapshot-id snap-0abc123 \ --availability-zone us-east-1a \ --volume-type gp3EBS vs Azure Managed Disks
Section titled โEBS vs Azure Managed Disksโ| Feature | AWS EBS | Azure Managed Disks |
|---|---|---|
| SSD tiers | gp3, io2, io1 | Standard SSD, Premium SSD, Ultra Disk |
| HDD tiers | st1, sc1 | Standard HDD |
| Snapshots | Yes (S3-backed, incremental) | Yes (incremental) |
| Encryption | AES-256 via KMS | SSE via Azure Key Vault |
| Max size | 64 TB | 32 TB (most types) |
| Multi-attach | io1/io2 only (16 instances) | Ultra Disk (shared disks) |
EFS โ Elastic File System
Section titled โEFS โ Elastic File SystemโEFS is a fully managed, scalable NFS (Network File System) that can be mounted by thousands of EC2 instances, containers (ECS/EKS), and Lambda functions simultaneously.
In Azure terms: EFS = Azure Files (NFS/SMB shares)
EFS vs EBS
Section titled โEFS vs EBSโ| Feature | EBS | EFS |
|---|---|---|
| Access | Single EC2 instance (usually) | Many instances simultaneously |
| Protocol | Block (mounted as disk) | NFS v4.1 |
| AZ scope | Single AZ | Multi-AZ (Regional) or Single-AZ |
| Scaling | Manual resize (Elastic Volumes) | Automatic, scales to petabytes |
| Use case | OS disk, databases | Shared config, content, code |
| Pricing | Provisioned size | Pay per GB used |
EFS Storage Classes
Section titled โEFS Storage Classesโ| Class | Description |
|---|---|
| Standard | Frequently accessed files |
| Standard-IA | Infrequently accessed (lower cost, retrieval fee) |
| One Zone | Single AZ, lower cost |
| One Zone-IA | Single AZ + infrequent access |
Lifecycle policies automatically move files to IA after 7, 14, 30, 60, or 90 days.
Mounting EFS
Section titled โMounting EFSโ# Install EFS mount helpersudo yum install -y amazon-efs-utils
# Mount EFS filesystemsudo mount -t efs -o tls fs-0abc123:/ /mnt/efs
# Add to /etc/fstab for persistencefs-0abc123:/ /mnt/efs efs defaults,_netdev,tls 0 0EFS with ECS/EKS
Section titled โEFS with ECS/EKSโEFS is commonly used as shared storage for containerized apps:
- ECS: Mount EFS volumes in task definitions
- EKS: Use the EFS CSI driver to create PersistentVolumes with
ReadWriteManyaccess mode
Storage Decision Guide
Section titled โStorage Decision Guideโ| Need | Choose |
|---|---|
| EC2 OS disk | EBS gp3 |
| High-performance database | EBS io2 |
| Shared files across many instances | EFS |
| Large object storage (files, backups, media) | S3 |
| Long-term archive | S3 Glacier |
| On-prem files to cloud | AWS Storage Gateway |