AWS EBS Volumes: Essential Storage for EC2 Instances
Filip Konkowski
Back-end engineer in enterprise banking, with a passion to new technologies like blockchain, deep learning and low-level hardware application
Welcome to this section where we explore the different storage options for EC2 instances. One of the most important storage solutions in AWS is EBS Volumes. Let’s define what they are and understand their critical role in data persistence and management for EC2 instances.
What Are EBS Volumes?
EBS stands for Elastic Block Store. It's a network drive that can be attached to your instances while they run. An essential feature of EBS volumes is their ability to persist data even after an instance is terminated. This means you can recreate an instance, mount the same EBS volume, and retrieve your data seamlessly. This is incredibly useful for data persistence and disaster recovery scenarios.
Key Characteristics:
How to Think of EBS Volumes
Think of EBS volumes as network-based USB sticks. You can detach them from one instance and attach them to another quickly without physically moving anything. This flexibility is crucial for tasks like failovers.
EBS volumes are network drives, meaning data travels over the network, which may introduce some latency. Despite this, their ability to be detached and reattached swiftly makes them highly useful for various applications.
Provisioning and Performance
When creating an EBS volume, you need to provision capacity in advance. This includes specifying the size in gigabytes (GB) and the IOPS (Input/Output Operations Per Second) for performance. You are billed for the provisioned capacity, and you can increase the size and performance as needed over time.
Diagram Illustration
Imagine you have an EC2 instance in us-east-1a with an EBS volume attached. If you create another EC2 instance, you cannot attach the same EBS volume to both instances simultaneously at the CCP level (except for io1 and io2 family Multi-Attach Feature) . Each instance needs its own EBS volume. However, you can attach multiple EBS volumes to a single instance, much like plugging in multiple USB sticks into a single computer.
EBS volumes are linked to an availability zone. So, if all your instances and volumes are in us-east-1a, you need to create new volumes in other availability zones if required. Additionally, you can create EBS volumes and leave them unattached, ready to be attached on demand.
Delete on Termination Attribute
When creating an EBS volume through the EC2 console, there is an attribute called "Delete on Termination." This attribute dictates whether the EBS volume should be deleted when the associated EC2 instance is terminated. By default, this is enabled for the root volume (the volume with the operating system) and disabled for additional EBS volumes.
Use Case:
If you want to preserve the root volume after an instance is terminated (for example, to save data), you can disable the "Delete on Termination" attribute for the root volume. This feature can be useful in scenarios where data preservation is critical, and it’s a potential topic in certification exams.
EBS Volume Types
EBS volumes come in six different types, each suited to different workloads and performance requirements. These can be broadly categorized into SSD and HDD volumes:
领英推荐
Key Factors in Defining EBS Volumes
When configuring EBS volumes, consider the following factors:
For EC2 instances, only gp2, gp3, io1, and io2 volumes can be used as boot volumes, which is where the root OS runs.
Use Cases and Recommendations
Practical Example: Using EBS Volumes
Here's a practical scenario to illustrate the use of EBS volumes:
Multi-Attach Feature
The Multi-Attach feature is a significant advancement for EBS volumes, allowing a single io2 or io1 volume to be attached to multiple EC2 instances within the same availability zone. This provides enhanced application availability and is particularly useful for clustered Linux applications and applications managing concurrent write operations.
Key Points about Multi-Attach:
Conclusion
Understanding and choosing the right EBS volume type is crucial for optimizing your AWS infrastructure's performance and cost. AWS EBS Volumes provide persistent, flexible, and reliable storage solutions tailored to meet the needs of various applications. Whether you need cost-effective storage, high IOPS for databases, or low-cost archival storage, EBS offers a variety of options to meet your needs. By understanding how to configure and use EBS volumes effectively, you can ensure your data remains safe, accessible, and ready for use across different instances and availability zones. Always consult AWS documentation for the latest best practices and updates, as this knowledge will help you optimize your current setup and prepare for AWS certification exams.