An EC2 machine instance in the AWS cloud requires persistent block storage. Amazon EBS – Elastic Block Storage provides persistent block storage for your instance. AWS EBS offers very low latency and consistent performance. With Amazon EBS, you can scale up or down at any point in time.
AWS provides a very flexible, easy-to-use and cost-effective storage option for your EC2 instances. There are several EBS options available on AWS. Each option has a different combination of durability and performance.
Moreover, to protect from the component failure, Amazon EBS comes with auto replication of the volume in the availability zone.
What is Amazon EBS?
Amazon EBS is an abbreviation of “Amazon Elastic Block Storage”. As most of the services of AWS, Amazon EBS is also an elastic service. Amazon EBS provides an elastic, high performance, low-latency persistent block storage in AWS cloud.
An Amazon EBS volume is an unformatted, raw, external block device that you can attach to a single instance. When we say instance that means Amazon EC2 instance. You can dynamically change or add the volume to your running EC2 instance.
AWS also provides encryption features. Amazon EBS volumes can be created as encrypted with the encryption features. Also, You can take backups of your EBS volumes by creating the snapshots.
Why Amazon EBS?
AWS provides countless benefits on why we should use Amazon EBS. Let’s discuss a few of many benefits:
1. Consistent with Low-Latency Performance
Amazon EBS general purpose (SSD) volumes provide very consistent performance with very low-latency. I/O performance is consistent and can be scaled to the needs of your application.
2. Backup & Restore
To protect your data, you can take backups by taking the snapshot at any point-in-time. The best thing is that AWS stores the snapshot incrementally. That means it only stores the data which has been changed from the last snapshot. This reduces the usage cost as well.
You can use the snapshots for backup purposes. Backup and restore of Amazon EBS are very fast and reliable.
3. Reliable
Amazon EBS is highly reliable as it replicates the volume in the availability zone. This protects from the component failure.
4. Secure Storage
AWS provides encryption feature to encrypt the EBS volumes to make them more secure. EBS encryption and access control policies deliver a strong defense-in-depth security strategy for your data.
5. Optimized Performance
Amazon EBS provides the best possible performance for your EBS volumes by minimizing the network connection between EC2 instance and EBS itself. Optimized instances provide optimized network capacity for your volumes.
6. Scalability
We keep saying that most of AWS services are highly scalable so the Amazon EBS. AWS provides you ability to optimize your volume in terms of performance, capacity, and cost. You can scale up and down EBS volumes at any point-in-time.
AWS EBS Volumes
AWS EBS volumes are the block-level storage devices which provide high durability. You can attach the EBS volume to a single EC2 instance at a time. These are primary storage devices which can be used for frequent updates.
Once the EBS volume is attached to your instance, you can use them just like any other physical hard drive.
Amazon EBS provides the following volume types:
- General Purpose SSD (gp2)
- Provisioned IOPS SSD (io1)
- Cold HDD (sc1)
- Throughput Optimized HDD (st1)
Let’s discuss them in two main category SSD and HDD.
Types of EBS Volumes
Amazon provides the below volume types. The volume differs in terms of performance, cost, and capacity. Before choosing a volume you must know about their offerings.
As I said earlier, you can mainly divide the volume types into two categories:
1. Solid-State Drives (SSD)
The devices backed with Solid-State Devices (SSD) is optimized for the transactional workload. Where you need very frequent read and write operation with small size I/O. The performance attribute here is IOPS (I/O operations per second).
(Reference: AWS – https://aws.amazon.com)
Use Cases
- Recommended for most workloads
- System boot volumes
- Virtual desktops
- Low-latency interactive apps
- Development and test environments
- Critical business applications that require sustained IOPS performance, or more than 16,000 IOPS or 250 MiB/s of throughput per volume
- Large database workloads, such as:
- MongoDB
- Cassandra
- Microsoft SQL Server
- MySQL
- PostgreSQL
- Oracle
Volume Type -> | General Purpose SSD (gp2) | Provisioned IOPS SSD (io1) |
---|---|---|
Description | General purpose SSD volume that balances price and performance for a wide variety of workloads | Highest-performance SSD volume for mission-critical low-latency or high-throughput workloads |
API Name | gp2 | io1 |
Volume Size | 1 GiB – 16 TiB | 4 GiB – 16 TiB |
Max. IOPS/Volume | 16,000 | 64,000 |
Max. Throughput/Volume | 250 MiB/s | 1,000 MiB/s |
Max. IOPS/Instance | 80,000 | 80,000 |
Max. Throughput/Instance | 1,750 MiB/s | 1,750 MiB/s |
Dominant Performance Attribute | IOPS | IOPS |
2. Hard Disk Drives (HDD)
The devices backed with Hard Disk Drives (HDD) are optimized for heavy streaming workloads. The performance measurement is in MiB/s (megabyte per second) which is a lot better than IOPS.
(Reference: AWS – https://aws.amazon.com)
Use Cases
- Streaming workloads requiring consistent, fast throughput at a low price
- Big data
- Data warehouses
- Log processing
- Cannot be a boot volume
- Throughput-oriented storage for large volumes of data that is infrequently accessed
- Scenarios where the lowest storage cost is important
- Cannot be a boot volume
Volume Type -> | Throughput Optimized HDD (st1) | Cold HDD (sc1) |
---|---|---|
Description | Low-cost HDD volume designed for frequently accessed, throughput-intensive workloads | Lowest cost HDD volume designed for less frequently accessed workloads |
API Name | st1 | sc1 |
Volume Size | 500 GiB – 16 TiB | 500 GiB – 16 TiB |
Max. IOPS/Volume | 500 | 250 |
Max. Throughput/Volume | 500 MiB/s | 500 MiB/s |
Max. IOPS/Instance | 80,000 | 80,000 |
Max. Throughput/Instance | 1,750 MiB/s | 1,750 MiB/s |
Dominant Performance Attribute | MiB/s | MiB/s |
Create an AWS EBS Volume
Let’s create an EBS volume for the EC2 instance.
-
- Login to your AWS account
- Go to management console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
- Choose the region from the top right navigation bar where you want to create the EBS volume.
- In the left navigation, click on “Volumes” in the ELASTIC BLOCK STORE. You will see the below screen.
Elastic Block Storage Option
-
- Click on the “Create Volume”. You will see the below screen where you will fill the required details.
Create EBS Volume
- In the above sections, we have discussed the Volume Types. Choose as per your need of the application. In the example, I’m choosing General Purpose SSD (gp2).
- For Size (GiB), type the size of the volume. In the example, we will take the default 100GiB size.
- IOPS – The requested number of I/O operations per second that the volume can support. For Provisioned IOPS (SSD) volumes, you can provision up to 50 IOPS per GiB. For General Purpose (SSD) volumes, baseline performance is 3 IOPS per GiB, with a minimum of 100 IOPS and a maximum of 10000 IOPS.
- Availability Zone – The Availability Zone in which to create the EBS volume. The volume will be available to instances in the same Availability Zone.
- You can leave other information to their default values for now and click on “Create Volume” button at the bottom.
Note: It will take a few seconds to create the volume, wait and you will see the success screen below with your EBS volume ID. EBS Volume Creation Confirmation
Click the “Close” button and page will be redirected to the volumes list and you can see your volume is there.
-
List EBS Volume
Attach EBS Volume with EC2 Instance
Once the EBS volume is created and available you can attach it to your EC2 instance. Let’s attach the volume to EC2 instance:
- Go to the management console then go to the EC2 at https://console.aws.amazon.com/ec2/.
- In the left navigation, click on “Volumes” in the ELASTIC BLOCK STORE.
- You will see the list of available volumes. Select the volume that you want to attach.
Option Attach EBS Volume With Instance
- Click on the “Action” and select “Attach Volume”
. You will see the below screen with tree fields Volume, Instance and Device. -
Attach EBS Volume
- For instance, type the Name of ID of your EC2 instance. The search will happen in the selected availability zone only (As i mentioned earlier that you will only see the instances from within the availability zone).
- Device Name – depends on the instance type that you are using. For Ex – Use “/dev/sd[f-p]” for your linux instance. We will talk about block device mapping in a separate post in detail.
- Click on “Attach”
Note: Though, your volume has been attached to your EC2 instance but you can use it after mounting it. You have to connect to your instance and mount the volume.
Mounting the volume is more an infra related work. If you still want to learn it then please comment below and let us know.
View EBS Volume Information
You can view all the information about the EBS volume that you created in below steps:
1. Information About EBS
- Go to the management console then go to the EC2 at https://console.aws.amazon.com/ec2/.
- In the left navigation, click on “Volumes” in the ELASTIC BLOCK STORE.
- You will see the list of available volumes. Select the volume you want to see the details of and you will see the below details:
View Volume Information
2. Information About EBS with EC2 Instance
- Go to the management console then go to the EC2 at https://console.aws.amazon.com/ec2/.
- In the left navigation, click on “Instances” in the INSTANCES section.
- Select the instance to view details of the EC2 instance.
- In the details pane, you can inspect the information provided about block and root devices.
Delete EBS Volume
If you no longer need the volume then you can delete it. After delete, all of its data is gone and you can no longer use the volume or attach it to EC2 instance.
The volume that you are going to delete must be in the available state. That means it should not be attached to any instance. If it is attached with an instance then you have to detach it to make it available for deletion.
Follow the below steps to delete the EBS volume:
- Go to the management console then go to the EC2 at https://console.aws.amazon.com/ec2/.
- In the left navigation, click on “Volumes” in the ELASTIC BLOCK STORE.
- You will see the list of available volumes. Select the volume and click on “Action” button and you will see an option “Delete Volume”.
Delete EBS Volume Option
- Click on the “Delete Volume” button and confirm “Yes, Delete”.
Delete EBS Volume Confirmation
Summary
AWS EBS is a great solution to store data in the cloud. It’s fast, reliable, secure, and easy to scale. There are options to choose from Hard-Disk drive or Solid-State drive. We can attach it to an EC2 instance and setup database servers for higher performance. The EBS volume can be easily deleted when it’s not used anymore.