Ace Cloud Interviews
🗄️

AWS Storage

EBS

High-performance block storage volumes attached to EC2 instances

Amazon EBS (Elastic Block Store) provides persistent block storage volumes that attach to EC2 instances like virtual hard drives, surviving instance stops and reboots. EBS volumes are AZ-specific, offer sub-millisecond latency, and come in SSD and HDD variants tuned for different I/O profiles. Understanding EBS volume types, IOPS provisioning, and snapshot mechanics is essential for designing performant and cost-efficient EC2-based workloads.

EBS Volume Types - SSD vs HDD

EBS offers four volume types split between SSD-backed (latency-sensitive, random I/O) and HDD-backed (throughput-oriented, sequential I/O). The correct choice dramatically impacts both cost and performance.

Volume TypeAPI NameMax IOPSMax ThroughputUse Case
General Purpose SSDgp316,0001,000 MB/sDefault for most workloads - boot volumes, dev/test, small DBs
General Purpose SSD (legacy)gp216,000250 MB/sOlder default - migrate to gp3 for better performance and cost
Provisioned IOPS SSDio2 Block Express256,0004,000 MB/sI/O-intensive DBs: Oracle, SQL Server, SAP HANA
Provisioned IOPS SSDio164,0001,000 MB/sLegacy high-performance, prefer io2
Throughput Optimized HDDst1500500 MB/sBig data, data warehouses, log processing
Cold HDDsc1250250 MB/sInfrequently accessed, lowest cost block storage
💡

gp3 is now the recommended default. Unlike gp2, gp3 decouples IOPS from volume size - you can provision up to 16,000 IOPS and 1,000 MB/s independently at no extra charge on volumes sized from 1GB. gp2 ties IOPS to volume size (3 IOPS/GB, burst up to 3,000).

⚠️

HDD volumes (st1, sc1) cannot be used as boot volumes. Only SSD volumes (gp2, gp3, io1, io2) can be root volumes.

IOPS, Throughput, and Performance Tuning

IOPS (I/O Operations Per Second) measures how many read/write operations a volume can handle. Throughput measures how much data moves per second. Understanding both is required for database workload sizing.

Conceptgp3 Defaultsgp3 Maxio2 Max
Baseline IOPS3,00016,00064,000 (256k on Block Express)
IOPS cost above baselineFree included$0.005/provisioned IOPS above 3,000$0.065/provisioned IOPS
Baseline Throughput125 MB/s1,000 MB/s4,000 MB/s
Throughput cost above baselineFree included$0.04/MB/s above 125Included

The EC2 instance itself also has EBS bandwidth limits - the volume cannot exceed what the instance supports:

bash
# Check EBS optimized baseline throughput for an instance type
aws ec2 describe-instance-types \
  --instance-types r6i.2xlarge \
  --query "InstanceTypes[].EbsInfo"

# Check current volume performance
aws cloudwatch get-metric-statistics \
  --namespace AWS/EBS \
  --metric-name VolumeReadOps \
  --dimensions Name=VolumeId,Value=vol-xxxxxxxxx \
  --start-time 2024-01-01T00:00:00Z \
  --end-time 2024-01-01T01:00:00Z \
  --period 60 \
  --statistics Sum
💡

EBS-optimized instances have dedicated bandwidth for EBS traffic, separate from the network. Most modern instance types are EBS-optimized by default. Always check instance-level EBS bandwidth limits when provisioning high-IOPS volumes.

Snapshots, AMIs, and Data Lifecycle

EBS snapshots are incremental backups stored in S3 (managed by AWS, not visible in your S3 console). The first snapshot is a full copy; subsequent snapshots only store changed blocks.

OperationBehaviorKey Detail
Create snapshotIncremental, captures changed blocksVolume can remain in use during snapshot
Restore from snapshotNew volume, lazy loadingData loads on first access - can cause latency spikes
Copy snapshotCopies to same or different regionUsed for DR and cross-region AMI sharing
Fast Snapshot Restore (FSR)Pre-warms blocks for immediate performanceCosts extra - charged per AZ per snapshot enabled
Snapshot sharingShare with specific accounts or publicShared snapshots are not billed to recipient for storage
bash
# Create a snapshot with a description
aws ec2 create-snapshot \
  --volume-id vol-xxxxxxxxx \
  --description "Pre-deployment backup 2024-01-15"

# Copy snapshot to another region for DR
aws ec2 copy-snapshot \
  --source-region us-east-1 \
  --source-snapshot-id snap-xxxxxxxxx \
  --destination-region eu-west-1 \
  --description "DR copy"

# Use DLM (Data Lifecycle Manager) to automate snapshots
aws dlm create-lifecycle-policy \
  --execution-role-arn arn:aws:iam::123456789:role/AWSDataLifecycleManagerDefaultRole \
  --description "Daily snapshots" \
  --state ENABLED \
  --policy-details file://dlm-policy.json
⚠️

When you restore a volume from a snapshot, the volume is created immediately but blocks are loaded lazily from S3 in the background. Production databases restored from snapshots can show severely degraded I/O until all blocks are pre-warmed. Use Fast Snapshot Restore or pre-warm by reading all blocks (dd if=/dev/xvda of=/dev/null) before going live.

Encryption and Multi-Attach

EBS encryption uses AWS KMS and encrypts data at rest, in transit between the instance and volume, and in snapshots. Multi-Attach allows one io1/io2 volume to attach to up to 16 Nitro-based EC2 instances simultaneously.

FeatureDetail
Encryption algorithmAES-256
Key optionsAWS managed key (aws/ebs) or customer managed KMS key
Encrypted volume from unencrypted snapshotPossible during copy - specify encryption and key
Unencrypted volume from encrypted snapshotNot possible
Multi-Attach supportio1 and io2 only, same AZ, up to 16 instances
Multi-Attach file system requirementCluster-aware file system required (e.g. GFS2, OCFS2) - ext4/XFS will corrupt
bash
# Enable encryption by default for new volumes in the account
aws ec2 enable-ebs-encryption-by-default --region us-east-1

# Create an encrypted volume with a custom KMS key
aws ec2 create-volume \
  --availability-zone us-east-1a \
  --size 100 \
  --volume-type gp3 \
  --encrypted \
  --kms-key-id arn:aws:kms:us-east-1:123456789:key/mrk-xxxxxxxxx
⚠️

Multi-Attach requires a cluster-aware file system. Using a standard file system like ext4 or XFS with Multi-Attach will result in data corruption because they do not handle concurrent writes from multiple hosts.

EBS Pricing and Cost Optimization

EBS costs are based on provisioned capacity and IOPS, not actual usage. You pay for what you provision, not what you use - making right-sizing critical.

Volume TypeStorage Cost (us-east-1)IOPS CostThroughput Cost
gp3$0.08/GB-month$0.005/IOPS above 3,000$0.04/MB/s above 125
gp2$0.10/GB-monthIncluded (3 IOPS/GB)Included
io2$0.125/GB-month$0.065/IOPS up to 32k; $0.046 up to 64kIncluded
st1$0.045/GB-monthIncludedIncluded
sc1$0.015/GB-monthIncludedIncluded
Snapshots$0.05/GB-monthN/AN/A
💡

Migrating from gp2 to gp3 typically saves 20% on storage costs while providing better baseline performance. Use AWS Compute Optimizer to identify oversized EBS volumes and volumes where gp2 to gp3 migration is recommended.

🎯

Interview Focus Points

  • 1What is the difference between gp2 and gp3 and why should you migrate existing gp2 volumes?
  • 2A database on EC2 is experiencing high latency. Walk me through how you would diagnose an EBS I/O bottleneck.
  • 3Explain how EBS snapshots work incrementally and what happens when you delete an intermediate snapshot.
  • 4What is EBS Multi-Attach and what file system requirements does it impose?
  • 5How would you ensure an EBS-backed EC2 instance can survive an AZ failure?
  • 6What is the "lazy loading" behavior when restoring an EBS volume from a snapshot and how do you handle it for production?
  • 7How do you encrypt an existing unencrypted EBS volume without downtime?
  • 8When would you choose io2 over gp3 for a database workload?
  • 9What is AWS Data Lifecycle Manager and how does it differ from creating snapshots manually?