AWS EC2 Instance Store

What is EC2 Instance Store

EC2 Instance Store is a type of storage that's physically attached to the host computer for the EC2 instance. Data on instance store volumes is temporary, meaning data can be lost if the instance stops, terminates, or fails.

Instance Store volumes are either NVMe or non-NVMe. NVMe (Non-Volatile Memory Express) is a protocol specifically designed for solid-state storage to make use of the capabilities of high-speed PCIe bus standards. Typically, they offer better performance compared to non-NVMe volumes due to the advantages of the NVMe protocol. They provide lower latencies and higher IOPS.

Advantages and Disadvantages

Advantages:

  • Performance. Instance store provides high IOPS (input/output operations per second) and low-latency performance because it’s directly attached to the host.

  • No Additional Cost: Instance store volumes are included as part of the instance’s hourly cost. You pay for the EC2 instance, and the storage is bundled with it.

Disadvantages

  • Ephemeral Nature: Data is lost on instance stop or termination. Always make sure to back up important data elsewhere.

  • Limited Size: The storage size is fixed depending on the instance type and can't be changed.

  • Not Detachable: You cannot detach an instance store from one instance and attach it to another.

The difference between EBS and Instance Store

  • Persistence: EBS volumes persist independently from the life of an instance, while instance store volumes are ephemeral.

  • Performance: The instance store may offer superior IOPS and throughput for certain workloads, but EBS has made significant strides, especially with its Provisioned IOPS and io2 block express volumes.

  • Features: EBS comes with features like snapshots, volume resizing, and the ability to detach/attach to different EC2 instances.

  • Cost: While the instance store is included in the instance price, EBS volumes have a separate cost based on provisioned storage and I/O.

Hands-on Lab Overview

The aim of this hands-on lab is to create an EC2 instance with instance store volumes, understand their temporary nature, and finally watch whether the data will be lost after the EC2 instance termination/stopped.

💡
Instance store volumes can be found only on specific EC2 instance types. These types usually are very performant and may require a lot of money charge. Be aware!

Hands-on Lab

  1. Create and launch an EC2 instance with the Instance type m1.small that supports an instance store volume. In the storage section, you'll notice the instance store volumes attached to this instance type.

  2. Once the instance is running, connect to the instance using an SSH client or EC2 Connect.

  3. Use the df -h command to view the volumes that are formatted and mounted.

  4. Use the lsblk to view any volumes that were mapped at launch but not formatted and mounted.

  5. To format and mount an instance store volume that was mapped only, do the following:

    • Create a file system on the device using the mkfs command.

        [ec2-user ~]$ sudo mkfs -t xfs /dev/nvme1n1
      
    • Create a directory on which to mount the device using the mkdir command.

        [ec2-user ~]$ sudo mkdir /data
      
    • Mount the device on the newly created directory using the mount command.

        [ec2-user ~]$ sudo mount /dev/nvme1n1 /data
      
  6. Navigate to the mounted directory, create a sample file, and confirm the data:

     cd /data
     echo "This is instance store data" > sample.txt
     cat sample.txt
    
  7. From the EC2 Dashboard or using the CLI, stop the EC2 instance and start the instance again.

  8. SSH back into the EC2 instance and navigate to

     cd /data
     ls
    

    You'll observe that the data is gone.

Summary

Instance store volumes provide temporary block-level storage for instances. The data on an instance store volume persists only during the life of its associated instance. If you stop or terminate an instance, the data on its instance store volumes is lost. This exercise gives a practical understanding of this characteristic. Remember to always back up data that you cannot afford to lose and consider using persistent storage options like Amazon EBS for long-term data storage.

References

  1. #40 Amazon EC2 Instance Store | Why and When to use?

  2. Amazon EC2 instance store

  3. Instance store volumes

  4. Add instance store volumes to your EC2 instance

  5. AWS EC2 Instance Store Storage

0
Subscribe to my newsletter

Read articles from Karlygash Yakiyayeva directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Karlygash Yakiyayeva
Karlygash Yakiyayeva

Postgraduate in Communications Engineering with working experience in the Support Desk and self-study in software development.