Friday, May 2, 2025

Amazon EC2 Instance: Storage types

Amazon EC2 Instance:  Storage types.

EBS Volume

• EBS (Elastic Block Store) Volume is a network drive that twtech can attach to its instances while they run.

• The attachment of ebs volume to an instance, enables that instance to persist data, even after that instance is terminated.

 • twtech can only mount the ebs volume to one instance at a time. 

Tips:

EC2 instance storage types and use-cases.

Summarized at the CCP(certified cloud partitional) level:

1. Instance Store (ephemeral storage)

  • Temporary, local storage physically attached to the EC2 host.
  • Data is lost if the instance stops or is terminated.
  • Use case: Temporary storage needs like caching or scratch data.

 2. Amazon EBS (Elastic Block Store)

  • Durable, persistent storage that attaches to EC2 instances.
  • Can store OS, databases, or application data.
  • Data remains even after stopping or terminating the instance (if not deleted).
  • Use case: Boot volumes, databases, critical app storage.

 3. Amazon EFS/NFS (Elastic File System/Network file system)

  • Shared file system that can be accessed by multiple EC2 instances.
  • Scales automatically as files grow.
  • Use case: Shared access for web servers, CMS, or analytics pipelines.

At CCP level: 

twtech-users are expected to:  

  •  Understand the difference between temporary (Instance Store) and persistent (EBS/EFS) storage.
  • Know when to use block storage (EBS) vs. file storage (EFS).
  • Recognize that Instance Store is not durable and is not used for critical data.

 •  know that EBS volumes are bound to a specific availability zone.

•  Thererfore, twtech EBS Volume in us-east-2a cannot be attached to us-east-1b.

 • Thererfore, twtech considers an ebs volume as a “network USB stick”.

 •  twtech can have Free tier for up to 30 GB of free EBS storage of type General Purpose (SSD) or Magnetic per month.

• EBS is a network drive (it is not a physical drive).

• The ebs volume uses the network to communicate between instances, and that accounts for the reasons behind latency.

•  twtech may detached its ebs volume from an EC2 instance and attached to another.

• twtech used snapshots to move a volume across.

• The ebs volume has a provisioned capacity of size in GBs, or IOPS.

A. GBs (Gigabytes per second)

  • Meaning: A measure of data transfer speed—how fast data can be read from or written to a storage device.

  • Example: If a drive has a speed of 2 GB/s, it can transfer 2 gigabytes of data every second.

  • Use caseImportant for tasks like copying large files, streaming high-resolution video, or loading big databases quickly.

B. IOPS (Input/Output Operations Per Second)

  • Meaning: A measure of how many individual read/write operations a storage system can handle per second.

  • Example: A drive with 10,000 IOPS can process 10,000 read or write commands each second.

  • Use case: Crucial for workloads with lots of small, random reads/writes, like databases or high-traffic web servers.

• twtech is billed for its provisioned ebs volumes.

• twtech may decide to increase or decrease the capacity of the drive over time by scaling their volumes vertically (same volume)  or horizontally (different  volumes). 


Advance-Settings:

Delete on termination, Controls the EBS behaviour when an EC2 instance terminates,

• By default, the root EBS volume is deleted (Yes).

• By default, any other attached EBS volume is not deleted (No).

• This can be managed via AWS console and  CLI.

twtech-addendum:

Amazon EC2 – Instance Storage types and usecases

Amazon EC2 offers several instance storage types, each designed for different performance characteristics and use cases. Here's a breakdown of the main storage options and when to use them.

 1. Instance Store (Ephemeral Storage)

Key Traits:

  • Physically attached to the host computer.
  • High IOPS, low latency.
  • Data is lost when the instance stops, hibernates, or terminates.
  • Cannot be detached or moved between instances.

 Use Cases:

  • Temporary data like cache, buffers, scratch data, or temporary logs.
  • Applications with high-speed, short-term storage needs (e.g., video processing, batch jobs).
  • High-performance NoSQL databases where persistence is handled elsewhere.

2.    Elastic Block Store (Amazon EBS)

Key Traits:

  • Network-attached, persistent block storage.
  • Survives instance stop/start/termination (if not explicitly deleted).
  • Can be snapshotted, resized, and attached/detached from instances.
  • Supports encryption and backup.

Types of EBS volumes:

Type

Key Feature

Use Case

gp3 / gp2

General Purpose SSD

Boot volumes, dev/test workloads

io2 / io1

Provisioned IOPS SSD

Databases like MySQL, PostgreSQL, Oracle

st1

Throughput Optimized HDD

Big data, data warehouses, log processing

sc1

Cold HDD

Infrequently accessed, low-cost storage

Use Cases:

  • Boot volumes, application storage.
  • Databases, transactional systems, persistent volumes.
  • Systems that need durability and reliability.

 3. Amazon EFS (Elastic File System) – Not EC2-specific, but often used with EC2

Key Traits:

  • Fully managed, elastic NFS file system.
  • Accessible by multiple EC2 instances across AZs.
  • Scales automatically.

Use Cases:

  • Shared file storage across EC2 instances.
  • CMS systems, web servers, data science pipelines.
  • Applications needing a common file system.

 4. Amazon FSx File storage optimized for specific workloads (e.g., FSx for Windows, Lustre)

 twtech-Summary Table

Storage Type

Persistent

Performance

Use Cases

Instance Store

❌ No

Very high

Cache, temp files, scratch data

EBS (gp3/io1/st1)

✅ Yes

Medium to high

Boot, databases, general workloads

EFS

✅ Yes

Shared, scalable

Shared file systems, multi-AZ access

FSx

✅ Yes

Specialized

Windows apps, HPC, Lustre file systems

How twtech configures and terminate its EC2 instance but retains the EBS root volume with its data still intact.

Step-by-Step in the AWS Console:

  1. Go to the EC2 Dashboard.
  2. Select the instance you want to terminate.
  3. Click the "Actions" dropdown, then go to:
    • Instance settingsChange Termination Protection Make sure it's disabled (select: NO).
  4. Now go to:
    • ActionsInstance settingsChange root volume delete behavior.
  5. Uncheck the box “Delete on termination” for the root volume (usually /dev/xvda or /dev/sda1).
    • Or go to Volumes, find the root volume attached to the instance, and:
    • Select it → Actions → Modify Volume Attachment → Uncheck "Delete on termination".
  6. Click Save.
  7. Now terminate the instance:
    • ActionsInstance StateTerminate instance.

Notes:

  • After termination, the root EBS volume will remain in your account, and twtech can:
    • Attach it to another EC2 instance.
    • Create a snapshot or AMI from it.
    • Mount it as a secondary volume to inspect or recover data.

 CLI Equivalent:

twtech can also use the AWS CLI:

#   bash

aws ec2 modify-instance-attribute \

    --instance-id i-xxxxxxxxxxxxxxxxx \

    --block-device-mappings "[{\"DeviceName\":\"/dev/xvda\",\"Ebs\":{\"DeleteOnTermination\":false}}]"

Then terminate the instance:

#  bash 

aws ec2 terminate-instances --instance-ids i-xxxxxxxxxxxxxxxxx

Project:

How twtech creates an ebs volume and attach it to an instance.

Go EC2 console and navigate to elastic block store, then: volumes


us-east-2 is selected because it  corresponds to zone where the instance is located. ( same AZ)

Add tags

Create volume:



Attach volume to instance in the same AZ. Make sure the state is:  available.

Select the instance and device name to attach volume to:

Verify that the volume has been attached to the instance:

Successfully, twtech-web-server storage has been horizontally scaled (another volume added)

How twtech detaches and delete unwanted ebs volumes that is attached to an instance:

First:

Detach volume from instance


Confirm to detach:


Next. Delete the detached volume: refresh the page if need be.

Confirm and detete volume:


NB:

If twtech terminates an instance, the root volume is destroyed because by default delete on termination is set: YES.

This can also be configure to, if need be : No (root-volume will not be deleted on termination of instance)

But the created and attached ebs volume remains available.

Verify that the instance (twtech-webserver) has only the root volume still attached:

Yes, 

No comments:

Post a Comment

Kubernetes Clusters | Upstream Vs Downstream.

  The terms "upstream" and "downstream" in the context of Kubernetes clusters often refer to the direction of code fl...