Elastic Block Store (EBS)¶
Amazon Elastic Block Store (EBS) is a scalable, high-performance block storage service designed for Amazon Elastic Compute Cloud (EC2) instances. It provides persistent storage that can be attached to EC2 instances to store data in a highly available and durable manner.
Key Features¶
1. Persistence and Durability¶
EBS volumes are designed to be highly durable, with data replicated within the same Availability Zone (AZ) to prevent data loss from hardware failures.
2. Scalability¶
You can dynamically scale the storage capacity of EBS volumes without disrupting operations, allowing your applications to adapt to changing workloads.
3. Performance Options¶
EBS offers a range of volume types with varying performance characteristics: - General Purpose SSD (gp2, gp3): Balanced price and performance for general workloads. - Provisioned IOPS SSD (io1, io2): High performance for mission-critical applications. - Throughput Optimized HDD (st1): Optimized for large, sequential workloads. - Cold HDD (sc1): Low-cost storage for infrequent access. - Magnetic Volumes (standard): Legacy storage option (deprecated in many regions).
4. Snapshots¶
EBS supports incremental snapshots to Amazon S3, allowing you to back up volumes at any point in time.
5. Encryption¶
Data stored on EBS volumes can be encrypted using AWS Key Management Service (KMS). Encryption includes data at rest, data in transit, and volume snapshots.
6. Multi-Attach¶
EBS io2 volumes support Multi-Attach, allowing a single volume to be attached to multiple EC2 instances within the same AZ.
7. Integration with EC2 Auto Scaling¶
EBS integrates seamlessly with EC2 Auto Scaling, ensuring that storage scales along with compute resources.
Volume Types¶
Volume Type | Use Case | Performance |
---|---|---|
gp2 (General Purpose SSD) | General-purpose workloads | Baseline: 3 IOPS/GB, burst up to 16,000 IOPS |
gp3 | General-purpose workloads | Baseline: 3,000 IOPS, adjustable up to 16,000 IOPS |
io1 | High-performance applications | Provisioned up to 64,000 IOPS |
io2 | Mission-critical, high-durability apps | Provisioned up to 64,000 IOPS with durability of 99.999% |
st1 (Throughput Optimized HDD) | Large, sequential I/O workloads | Max throughput: 500 MiB/s |
sc1 (Cold HDD) | Infrequent data access | Max throughput: 250 MiB/s |
Common Use Cases¶
- Relational Databases: Store transactional data for applications like MySQL, PostgreSQL, and Oracle.
- Big Data Analytics: Provide high throughput for processing large datasets in Hadoop and Spark.
- Content Management Systems: Host media files or application data.
- Backup and Recovery: Use snapshots to create point-in-time backups and ensure business continuity.
- Boot Volumes: Serve as boot devices for EC2 instances.
- Shared File Systems: Support shared storage with Multi-Attach-enabled volumes.
Snapshots¶
Key Features of Snapshots:¶
- Incremental Backups: Only changes since the last snapshot are saved, reducing storage costs.
- Cross-Region Copy: Snapshots can be copied to other regions for disaster recovery.
- Lifecycle Policies: Automate snapshot creation and retention using Amazon Data Lifecycle Manager.
Creating a Snapshot:¶
Using AWS CLI:
aws ec2 create-snapshot \
--volume-id vol-0abcd1234efgh5678 \
--description "My EBS Snapshot"
Restoring from a Snapshot:¶
Using AWS CLI:
aws ec2 create-volume \
--snapshot-id snap-0abcd1234efgh5678 \
--availability-zone us-east-1a
Encryption¶
How EBS Encryption Works¶
- Encryption uses AWS KMS-managed keys or customer-managed keys.
- Encryption applies to data at rest, data in transit between the volume and the instance, and all backups.
Enabling Encryption:¶
- Default Encryption: Enable default encryption for all new volumes in your AWS account.
- Volume-Specific Encryption: Specify encryption when creating a volume.
Using AWS CLI:
aws ec2 create-volume \
--size 10 \
--availability-zone us-east-1a \
--encrypted
Performance Optimization¶
1. Choose the Right Volume Type¶
- Match volume type to workload characteristics (e.g., SSD for random I/O, HDD for sequential workloads).
2. Monitor Performance Metrics¶
- Use Amazon CloudWatch to monitor IOPS, throughput, and latency.
3. Use Elastic Volumes¶
- Modify volume size, type, or IOPS without downtime.
Pricing¶
EBS costs depend on several factors: 1. Volume Type: Cost per GB varies by type (e.g., gp3 vs. io2). 2. Provisioned IOPS: Additional charges for provisioned IOPS for io1/io2 volumes. 3. Snapshots: Charged based on the storage used by the snapshot. 4. Data Transfer: Charges may apply for data transfer across regions.
Refer to the EBS Pricing Page for detailed information.
Limits and Considerations¶
Limits:¶
- Volume Size: Up to 16 TiB.
- IOPS: Up to 64,000 IOPS (for io1/io2).
- Throughput: Up to 1,000 MiB/s.
- Provisioned IOPS Ratio: The maximum ratio of provisioned IOPS to volume size is 50:1 for io1 and io2 volumes.
Considerations:¶
- AZ-Specific: Volumes are tied to a specific AZ; cross-AZ usage requires snapshots or replication.
- Performance Throttling: Exceeding IOPS/throughput limits can lead to throttling.
- Data Durability: Snapshots are critical for long-term data durability.
Best Practices¶
- Backup Regularly: Use snapshots for periodic backups.
- Use Tags: Organize EBS volumes and snapshots with meaningful tags.
- Monitor Costs: Regularly analyze usage and optimize volume types to control costs.
- Use Elastic Volumes: Resize or change volume types as workloads evolve.
- Enable Encryption: Protect sensitive data with EBS encryption.
For more details, refer to the EBS Documentation.