Day 43 : AWS EBS (Elastic Block Store) (Jan 08, 2024)

Day 43 : AWS EBS (Elastic Block Store) (Jan 08, 2024)

  • EBS stands for Elastic Block Store.

  • EC2 is a virtual server in a cloud while EBS is a virtual disk in a cloud.

  • Amazon EBS allows you to create storage volumes and attach them to the EC2 instances.

  • Once the storage volume is created, you can create a file system on the top of these volumes, and then you can run a database, store the files, applications or you can even use them as a block device in some other way.

  • Amazon EBS volumes are placed in a specific availability zone, and they are automatically replicated to protect you from the failure of a single component.

  • EBS volume does not exist on one disk, it spreads across the Availability Zone. EBS volume is a disk which is attached to an EC2 instance.

  • EBS volume attached to the EC2 instance where windows or Linux is installed known as Root device of volume.

EBS Volume Types :

11.png

Amazon EBS provides two types of volume that differ in performance characteristics and price. EBS Volume types fall into two parts:

  • SSD-backed volumes

  • HDD-backed volumes

SSD :

  • SSD stands for solid-state Drives.

  • In June 2014, SSD storage was introduced.

  • It is a general purpose storage.

  • It supports up to 4000 IOPS which is quite very high.

  • SSD storage is very high performing, but it is quite expensive as compared to HDD (Hard Disk Drive) storage.

  • SSD volume types are optimized for transactional workloads such as frequent read/write operations with small I/O size, where the performance attribute is IOPS.

SSD is further classified into two parts

22.png

  • General Purpose SSD

  • Provisioned IOPS SSD

General Purpose SSD

  • General Purpose SSD is also sometimes referred to as a GP2.

  • It is a General purpose SSD volume that balances both price and performance.

  • You can get a ratio of 3 IOPS per GB with up to 10,000 IOPS and the ability to burst up to 3000 IOPS for an extended period of time for volumes at 3334 GiB and above. For example, if you get less than 10,000 IOPS, then GP2 is preferable as it gives you the best performance and price.

Provisioned IOPS SSD

  • It is also referred to as IO1.

  • It is mainly used for high-performance applications such as intense applications, relational databases.

  • It is designed for I/O intensive applications such as large relational or NOSQL databases.

  • It is used when you require more than 10,000 IOPS.

HDD :

  • It stands for Hard Disk Drive.

  • HDD based storage was introduced in 2008.

  • The size of the HDD based storage could be between 1 GB to 1TB.

  • It can support up to 100 IOPS which is very low.

33.png

Throughput Optimized HDD (st1)

  • It is also referred to as ST1.

  • Throughput Optimized HDD is a low-cost HDD designed for those applications that require higher throughput up to 500 MB/s.

  • It is useful for those applications that require the data to be frequently accessed.

  • It is used for Big data, Data warehouses, Log processing, etc.

  • It cannot be a boot volume, so it contains some additional volume. For example, if we have Windows server installed in a C: drive, then C drive cannot be a Throughput Optimized Hard disk, D: drive or some other drive could be a Throughput Optimized Hard disk.

  • The size of the Throughput Hard disk can be 500 GiB to 16 TiB.

  • It supports up to 500 IOPS.

Cold HDD (sc1)

  • It is also known as SC1.

  • It is the lowest cost storage designed for the applications where the workloads are infrequently accessed.

  • It is useful when data is rarely accessed.

  • It is mainly used for a File server.

  • It cannot be a boot volume.

  • The size of the Cold Hard disk can be 500 GiB to 16 TiB.

  • It supports up to 250 IOPS.

Magnetic Volume

  • It is the lowest cost storage per gigabyte of all EBS volume types.

  • It is ideal for the applications where the data is accessed infrequently

  • It is useful for applications where the lowest storage cost is important.

  • Magnetic volume is the only hard disk which is bootable. Therefore, we can say that it can be used as a boot volume.

Volumes Attached to One Instance :

Each account will be limited to 20 EBS volumes. For a requirement of more than 20 EBS volumes, contact Amazon’s Support team. We can attach up to 20 volumes on a single instance and each volume ranges from 1GB to 1TB in size.

In EC2 instances, we store data in local storage which is available till the instance is running. However, when we shut down the instance, the data gets lost. Thus, when we need to save anything, it is advised to save it on Amazon EBS, as we can access and read the EBS volumes anytime, once we attach the file to an EC2 instance.

Amazon EBS Benefits :

  • Reliable and secure storage − Each of the EBS volume will automatically respond to its Availability Zone to protect from component failure.

  • Secure − Amazon’s flexible access control policies allows to specify who can access which EBS volumes. Access control plus encryption offers a strong defense-in-depth security strategy for data.

  • Higher performance − Amazon EBS uses SSD technology to deliver data results with consistent I/O performance of application.

  • Easy data backup − Data backup can be saved by taking point-in-time snapshots of Amazon EBS volumes.

How to Set Up Amazon EBS?

Step 1 − Create Amazon EBS volume using the following steps.

  • Open the Amazon EC2 console.

  • Select the region in the navigation bar where the volume is to be created.

  • In the navigation pane, select Volumes, then select Create Volume.

  • Provide the required information like Volume Type list, Size, IOPS, Availability zone, etc. then click the Create button.

The volume names can be seen in the volumes list.

Step 2 − Store EBS Volume from a snapshot using the following steps.

  • Repeat the above 1 to 4 steps to create volume.

  • Type snapshot ID in the Snapshot ID field from which the volume is to be restored and select it from the list of suggested options.

  • If there is requirement for more storage, change the storage size in the Size field.

  • Select the Yes Create button.

Step 3 − Attach EBS Volume to an Instance using the following steps.

  • Open the Amazon EC2 console.

  • Select Volumes in the navigation pane. Choose a volume and click the Attach Volume option.

  • An Attach Volume dialog box will open. Enter the name/ID of instance to attach the volume in the Instance field or select it from the list of suggestion options.

  • Click the Attach button.

  • Connect to instance and make the volume available.

Step 4 − Detach a volume from Instance.

  • First, use the command /dev/sdh in cmd to unmount the device.

  • Open the Amazon EC2 console.

  • In the navigation pane, select the Volumes option.

  • Choose a volume and click the Detach Volumes option.

  • A confirmation dialog box opens. Click the Yes, Detach button to confirm.

How to upgrade the EBS Volume in various ways :

  • Sign in to the AWS Management Console.

  • Move to the EC2 service.

  • Create an EC2 instance.

  • Choose an Amazon Machine Image (AMI).

  • Choose an Instance type. Suppose I choose a t2.micro type for our EC2 instance. Click on the Next.

1.png

  • Configure Instance details. Keep all the details as default, and then click on the Next.

2.png

  • Add the EBS Volume. Root is the default EBS volume used to store the operating system.

3.png

I create three EBS Volumes of type Magnetic, Throughput Optimized HDD and Cold HDD.

  • Add tags.

4.png

  • Configure Security Group. Click on the Review and Launch.

  • Click on the Launch button.

  • Move to the Volumes appearing on the left side of the console.

5.png

From the above screen, we observe that a single EC2 instance is associated with four EBS Volumes type.

  • We can also modify the volume. Suppose I want to modify the volume type of gp2, check the EBS Volume that you want to modify.

6.png

  • Click on the Actions dropdown menu, click on the Modify Volume.

7.png

8.png

From the above screen, we observe that we can also modify the volume type. Standard cannot be modified as it is the oldest storage available. Therefore, we can say that all the volumes are modifiable apart from the magnetic storage volume.

  • Suppose I want to create another EBS Volume or EC2 instance in another Availability Zone. In order to achieve this, we first need to create a snapshot. Move to the Actions dropdown menu, then click on the Create Snapshot.

9.png

Move to the snapshot appearing on the left side of the console.

10.png

The above screen shows the snapshot that you have created just now.

Move to the Actions dropdown menu, click on the Create Volume.

11.png

12.png

From the above screen, we observe that we can change the Availability zone of a Volume for a snapshot that we have just created. Therefore, we have created a new EBS Volume with different Availability zone, i.e., us-east-2b.

  • You can also move an EC2 instance from one region to another region. In order to achieve this, the following steps are to be taken:Create a Snapshot.Move to the Actions dropdown menu, click on the copy.

13.png

  • The screen shown below shows that the snapshot has been copied to a new region, i.e., US West.

14.png

  • Once the snapshot is in a different region, create the image of the snapshot by clicking on the Actions dropdown menu, and then click on the Create Image.

15.png

  • Click on the Create button.

  • Move to the AMI appearing on the left side of the console. An AMI displays the image that you have just created.

16.png

  • Click on the Launch button.

Note: If you delete an EC2 instance, then root device is deleted, and other EBS Volumes are not deleted.

Important points to be noted:

  • Volumes exist on EBS. Volume is a Virtual Hard Disk which stores the operating system.

  • Snapshots exist on S3. However if you look at a bucket and searches for the snapshots in a bucket, you will not be able to see the snapshots. Therefore, we can say that the snapshot has no visibility.

  • Snapshots are a point in time copies of volumes. It's just like taking a photograph of the hard disk at a point of time.

  • Snapshots are incremental means the blocks that have been changed since your last snapshot are moved to S3.

  • The first snapshot always takes some time to create.

  • To create a snapshot for Amazon EBS Volumes that serve as root devices, you should stop the instance before taking the snapshot.

  • However, you can take a snapshot while the instance is running.

  • You can create AMI from snapshots.

  • You can change the EBS Volume size and storage type.

  • The Volume will always be in the same availability zone as the EC2 instance.

  • To move an EBS Volume from one region to another, take a snapshot of it, and then copy it to the new region.