What Is Amazon EBS and How Does It Work With EC2?
Amazon Elastic Block Store is a cloud storage service that provides scalable, high-performance block-level storage volumes for Amazon Elastic Compute Cloud instances. Unlike ephemeral instance store volumes that lose data when a virtual machine stops, Amazon Elastic Block Store preserves data independently of the compute instance lifecycle. It achieves persistence and reliability by automatically replicating data within an Availability Zone, making it ideal for databases, enterprise applications, and boot volumes.
Understanding Block-Level Storage
Block storage operates by dividing data into fixed-size chunks called blocks. Each block is assigned a unique address, and the storage system manages where these blocks are physically placed on the underlying hardware. When an Amazon Elastic Compute Cloud (EC2) instance interacts with an Amazon Elastic Block Store (EBS) volume, it treats the volume like a physical hard drive connected directly to the server.
Because EBS operates at the block level, you can format the volume with a file system of your choice, such as ext4, XFS, or NTFS. This low-level access allows applications like relational and NoSQL databases to modify individual blocks of data without rewriting entire files, resulting in low latency and high throughput.
How Amazon EBS Provides Persistent Storage
By default, some EC2 instance types come with local storage known as an instance store. While fast, instance store volumes are ephemeral; if the underlying host fails or the instance is stopped, all data on that storage is lost. Amazon EBS solves this by decoupling the storage lifecycle from the compute lifecycle.
Independent Volume Lifecycle
An EBS volume exists independently of the EC2 instance to which it is attached. When you stop an EC2 instance, the attached EBS root volume and any data volumes remain intact. When you restart the instance, it boots back up with all previously saved files, configurations, and application states preserved. You can also detach an EBS volume from one EC2 instance and attach it to another instance within the same Availability Zone to migrate workloads or recover from instance issues.
Availability Zone Replication
To protect against hardware failures, Amazon EBS automatically replicates every volume within its Availability Zone. If a physical drive in the AWS data center fails, the redundant copy ensures that your data remains available without interruption to your running EC2 instance. For most general-purpose volumes, AWS designs EBS to offer an annual failure rate (AFR) between \(0.1\%\) and \(0.2\%\), while high-end mission-critical volumes are designed for \(99.999\%\) durability.
Point-in-Time Snapshots
While EBS volumes live within a single Availability Zone, Amazon EBS supports point-in-time backups called snapshots, which are stored in Amazon Simple Storage Service (Amazon S3) across multiple Availability Zones. Snapshots are incremental, meaning only the blocks on the device that have changed after your most recent snapshot are saved. If a snapshot of size \(S_{\text{total}}\) consists of initial blocks \(B_0\) and subsequent changed blocks \(\Delta B_i\) over \(n\) intervals, the total storage consumed is represented by:
\[S_{\text{total}} = B_0 + \sum_{i=1}^{n} \Delta B_i\]
From any snapshot, you can create a new EBS volume in the same Availability Zone, a different Availability Zone, or even copy the snapshot to another AWS Region for disaster recovery.
Network-Attached Architecture
Unlike physical drives slotted directly into a host server, EBS volumes are network-attached storage devices that communicate with EC2 instances over the AWS high-speed internal network. Modern EC2 instances use the AWS Nitro System, which offloads storage virtualization and encryption tasks to dedicated hardware. This architecture minimizes latency and ensures that storage traffic does not contend with your standard application network traffic on EBS-optimized instances.
Types of Amazon EBS Volumes
Amazon EBS categorizes its storage options into two main technologies: solid-state drives (SSD) for transactional, IOPS-intensive workloads, and hard disk drives (HDD) for throughput-intensive workloads.
Solid-State Drive (SSD) Volumes
- General Purpose SSD (gp3 and gp2): Designed for a
balance of price and performance. They are commonly used for system boot
volumes, virtual desktops, and small-to-medium databases. With
gp3, you can scale IOPS and throughput independently of storage capacity. - Provisioned IOPS SSD (io2 Block Express and io1): Engineered for mission-critical, low-latency, and high-throughput workloads such as large relational databases (Oracle, Microsoft SQL Server, PostgreSQL). They provide sustained IOPS performance and the highest durability among EBS offerings.
Hard Disk Drive (HDD) Volumes
- Throughput Optimized HDD (st1): A low-cost magnetic storage option designed for frequently accessed, throughput-intensive workloads with large datasets, such as big data analytics, data warehouses, and log processing.
- Cold HDD (sc1): The lowest-cost EBS volume type,
built for less frequently accessed data where sequential throughput is
more important than fast random access. Note that HDD volumes
(
st1andsc1) cannot be used as boot volumes for EC2 instances.
Key Features for Enterprise Workloads
Elastic Volumes
With the Elastic Volumes feature, you can dynamically increase volume size, adjust IOPS and throughput performance, or change the volume type while the volume is attached and in use. This eliminates the need to schedule downtime for storage capacity upgrades.
EBS Multi-Attach
For specific Provisioned IOPS SSD (io1 and
io2) volumes, Amazon EBS supports Multi-Attach, which
allows a single volume to be concurrently attached to up to 16
Nitro-based EC2 instances within the same Availability Zone. This is
designed for clustered applications that manage concurrent write
operations to shared storage.
Built-In Encryption
Amazon EBS integrates with AWS Key Management Service (AWS KMS) to provide seamless encryption of data at rest, data in transit between the EC2 instance and the volume, and all snapshots created from the volume. Encryption is handled on the EC2 host hardware, ensuring minimal impact on storage performance.