Beginners Guide to AWS Elastic Block Store - EBS

Beginners Guide to AWS Elastic Block Store - EBS

Go-to Network Storage for EC2 Applications and Workloads

Dennis Groß's photo
Dennis Groß
·May 23, 2022·

6 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

AWS Elastic Block Store (EBS) provides storage volumes for EC2 instances. The storage is not located within the EC2 servers. Instances reach attached EBS volumes through a network which comes with a small latency compared to other storage forms like instance store.

EBS provides different volume types and offers flexible capacity as well as on-demand up and downscaling. That makes EBS the go-to service for most storage needs for applications running on EC2 instances.

Volume Types

EBS offers four different storage types.

  • gp2/gp3 - General Purpose SSD with a balanced price-/performance ratio, great for databases on development systems and workloads of all kinds.

  • io1/io2 - Provisioned IOPS SSD for I/O intensive applications in production systems.

  • st1 - Throughput optimized HDD for workloads that rely on high data transfer speeds rather than I/O operations.

  • sc1 - Cold HDD storage with reasonable throughput for infrequent data access such as logs and archives.

These storage types differ in

  • Capacity - min and a max capacity of the volume (in GiB - TiB)

  • Max IOPS/per volume - max amount of input-/output operations per volume block (in 16 KiB I/O)

  • Max throughput - max data transfer rates (in MiB/s)

  • EBS Multi-attach Support - EBS volumes with multi-attach support can be attached to multiple EC2 instances in the same AZ at the same time.

  • Boot Volume Support - EBS volumes with boot volume support can be used as root volumes in EC2 instances. Root volumes contain the AMI image of an EC2 instance.

EBS Hands-On

The EBS interface in the AWS console can be found within the EC2 instance interface.

EBS volumes are bound to a region and availability zone (AZ) which you need to select when you create the volume. Once created, EBS volumes can only be attached to EC2 instances running in the same AZ (and region). You can attach a volume to an either stopped or running EC2 instance.

You can inspect the EC2 instance details view to find the mount point of your EBS volume under Devices when the attachment operation is complete. The attached EBS volume may not be usable for your EC2 instance operating system right away. You need to format and mount the freshly attached disk first. AWS provides a detailed guide for the default Linux EC2 AMI here.

An EBS volume can be attached as an ephermal or persistent disk.

  • ephermal volumes get deleted upon termination of the EC2 instance it is attached to.

  • persistent volumes remain intact after the termination of the EC2 instance.

The DeletionOnTermination flag on the attached EBS volumes of an EC2 instance determines whether the volume gets erased (ephermal volume) or remains active (persistent volume). EC2 root volumes set the DeleteOnTermination flag by default to true, and additional attached EBS volumes set the flag by default to false.

You can change the value of the DeleteOnTermination flag for running EC2 instances with the AWS CLI following this tutorial.

Snapshots and the Recycle Bin

You can create a backup of an EBS volume also called snapshots. You can find the Snapshots near the EBS volume interface in the AWS console.

Snapshots can be taken of EBS volumes whether they are attached or not. Theoretically, it is even possible to snapshot an EBS volume of a running EC2 instance but that's not recommended. Performing a snapshot of an EBS volume occupies some of the volume throughputs which is not optimal when you run a productive workload like a database.

If possible, stop your EC2 instance when you perform a snapshot on one of the attached EBS volumes.

Snapshots are bound only to your EBS volume region but not AZ. This gives you an option to restore your volume snapshot into a volume of another AZ, effectively copying your EBS data from one AZ to another.

A full snapshot copies all data on an EBS volume but it is often better to perform incremental snapshots of your volume instead. An incremental snapshot copies only change of an EBS volume since the last snapshot and thus results in smaller snapshot sizes.

Incremental snapshots are beneficial for three reasons.

  • Cost-saving - snapshots on AWS cost per GiB/month, incremental backups greatly reduce the total snapshot size.

  • Faster Snapshots - an incremental snapshot can be performed faster than a full snapshot.

  • More Flexibility - due to the higher performance and smaller size, incremental snapshots can be performed in shorter periods and offer you more recovery points.

Archiving snapshots is another great way of saving snapshots costs. The snapshot archive is lower-tier storage for EBS volume snapshots and costs 75% less in comparison. Archiving an existing EBS volume snapshot is as easy as right-clicking on the volume and hitting archive.

Archived snapshots can take up to three days to recover, so avoid archiving important backups of production applications like databases when you cannot wait for the recovery in the worst case.

Ultimately, the cheapest option is to delete a snapshot. Some of you might feel a bit uneasy about deleting snapshots, especially when you deal with snapshots of the critical infrastructure like databases.

The EBS recycle bin solves that problem and keeps deleted snapshots around. You have to create a retention policy to activate the recycle bin for EBS snapshots, it is not activated by default. Here is a neat tutorial by AWS that explains how you can set up your recycle bin retention policy.

Summary

EBS provides network volumes that you can attach to running or stopped EC2 instances.

The DeleteOnTermination flag for an EBS volume determines whether the volume gets erased upon termination of the attached EC2 instance (ephermal) or not (persistent). EC2 root volumes set the DeleteOnTermination flag by default to true, any additional EBS volume that you attach will set the flag to false.

You can create snapshots of your EBS volumes and it is recommended to stop an EC2 instance before you take a snapshot of any attached volume. Snapshots are not for free and cost per Gib/month. Incremental snapshots or archiving the snapshots can reduce the overall cost of your snapshots.

AWS provides a recycle bin for deleted snapshots. The bin is not activated by default, you can activate it by defining a retention policy.

Glossary

  • instance store - EC2 storage solution that is physically located within the EC2 server resources. The instance store offers the highest IOPS compared with other storage solutions but is fully ephermal.

  • region -physical location of a cluster of AWS data centers. A region consists of multiple availability zones.

  • *availability zone (AZ) - one or more data centers located within the same region. Data centers must offer independent computing, storage, and network resources.

  • network storage - storage that is not integrated into the server hardware but provided through dedicated disks and reachable through a network layer.

  • incremental snapshots - a backup strategy that you perform periodically to backup only data changes from a volume since the last snapshot.

  • archiving - transferring data to a lower-tier storage type.

  • latency - delay that you have to wait before a data transaction happens after you send an instruction.

  • throughput - bandwidth of data operations on a storage medium in MiB/sec.

  • IOPS - input-/output operations per second

  • storage capacity - total size of an storage volume in MiB, GiB or TiB

Did you find this article valuable?

Support Dennis Groß by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
 
Share this