AWS

Difference between EBS backed and instance store instances

AWS EC2 supports two types of storage volumes: EBS backed volumes and instance-store volumes. While launching an EC2 instance, along with the other specifications like CPU and RAM, we need to select the storage for the instance in which the filesystem, operating system, and other data are stored. This storage device may be an EBS block storage or instance store volume. This blog will discuss the difference between these two storage types provided by AWS.

Instance Store instances

An instance store is a temporary storage for the EC2 instance, and data stored in the instance store is losts when the instance is stopped. Instance store volume is best for the use cases where data is temporarily stored like buffers and caches. Unlike EBS volumes, the instance store disk is physically attached to the host EC2 instance, making it more efficient. An instance store is the collection of one or more instance store volumes displayed as block devices.

Instance store lifetime

As discussed earlier, the data stored in the instance store is temporary, and it is best used when we need temporary data storage. Instance store volume is specified only when an EC2 instance is being launched and can not be detached and attached to another EC2 instance.

The instance store volume persists data inside it only when it is associated with an EC2 instance. When an EC2 instance is rebooted, the data inside the instance store volume persists. However, instance store volume loses its all data when any of the following happens.

  • Instance is stopped
  • Instance is hibernated
  • Instance is terminated
  • Hard drive fails

In the case of long-term data, instance store volume should not be preferred. Instead, use some durable storage services from AWS like Amazon EBS, Amazon EFS, or Amazon S3. When an instance store instance is stopped, hibernated, or terminated, every block of instance store volume is reset. So the data inside the instance store volume can not be accessed through another EC2 instance.

If an AMI is created from an instance store instance and a new instance is launched using the AMI. The data from the instance store will not be preserved on the new instance. Similarly, if the instance type of the instance store instance is changed, the instance store volume will not be attached to the new instance.

Instance store volumes

The size and the type of instance store volume hardware are determined by the instance type you use. Instance store volumes are specified while launching an instance store EC2 instance. All the AMIs from AWS do not support instance store volumes; hence you can use some specific AMIs for instance store volumes.

The benefit of using the instance store volumes is that they are physically attached to the instance hardware, so they are highly efficient. The instance store volumes are mostly used where data persistence is not a primary function, and high performance is needed. The best use case for these instance store volumes is cache servers.

EBS backed instances

EBS backed instances are the instances that are connected to the storage drives over the network. Unlike instance store volumes, these storage drives are not connected physically to the instances but are accessed by the instances over the network. These drives result in slow performance, but the data is persistent on the drives.

EBS (Elastic block storage) volumes are flexible, and the characteristics of these volumes can be changed at any time. You can change the volume size, volume type, and provisioned IOPS of the volume connected to the production instance without downtime. These volumes can also be used for data that is frequently updated, like database storage or root drive of the instance.

Multiple EBS volumes can be attached to the same instance, and for this, the instance and the EBS volumes must be in the same availability zone. You can also create an EBS volume without connecting it to any instance. Similarly, an EBS volume can also be connected to multiple instances depending upon the instance and volume type.

Benefits of EBS volumes

This section will discuss some benefits that are not provided by the instance store volumes. Following is the list of benefits of using the EBS volumes with an EC2 instance.

  • Flexibility
  • Data availability
  • Data persistence
  • Data encryption
  • Snapshots

Flexibility
EBS volumes are flexible and can be modified on production without bearing any downtime. The characteristics of the EBS volumes, like the size of the volume, provisioned IOPS, and volume type, can be changed easily. This flexibility can be used to save the cost of the storage by changing the characteristics of the EBS volume at any time.

Data availability
When an EBS volume is created, the data of the EBS volume is automatically replicated within the availability zone to prevent data loss in case of underlying hardware failure. The EBS volume can be detached and then attached to another instance to access the data.

Data persistence
EBS volumes can be created independently without attaching them to any EC2 instance. Also, you can detach an EBS volume with some data in it from an EC2 instance. These EBS volumes can persist data inside them independently. Any time you want to access your data from EBS volume, attach it with any existing or new EC2 instance, and the data can be accessed through EC2 instance.

Data encryption
Amazon EBS volumes also support encryption at rest using AWS KMS keys or customer-managed keys. Encryption at rest is supported by all the EBS volume types. All the encrypted EBS volumes use 256-bit Advanced Encryption Standard (AES-256) for encryption. By default, the AWS-managed key is used to create the encrypted EBS volumes, and AWS creates a default KMS key for EBS volumes.

Snapshots
Another benefit of using the EBS volumes instead of instance store volumes is that you can create a snapshot of the EBS volumes for backup. These snapshots can be used to recover the data at that point in time the snapshot was created. Snapshots can also be used to move EBS volumes to another region or availability zone. After moving the snapshot across the region, the EBS volume is restored from the snapshot and can be attached to another instance in another region.

Conclusion

AWS provides two different types of volumes attached to the EC2 instances that are EBS volumes and instance store volumes. Both EBS and instance store volumes can be used with EC2 instances depending upon the use case. The main difference between both volumes is that the instance store volume should not be used for long-term data storage; instead, use the EBS volume. For improved performance, instance store volumes are way better than that of EBS. This blog describes detailed information, use cases, and benefits of both of the volumes.

About the author

Zain Abideen

A DevOps Engineer with expertise in provisioning and managing servers on AWS and Software delivery lifecycle (SDLC) automation. I'm from Gujranwala, Pakistan and currently working as a DevOps engineer.