Multi-Attach and Storage Comparison
Learn how to use Amazon EBS Multi-Attach safely and effectively in multi-instance setups and understand how to choose between EBS, EFS, and instance store based on durability, performance, and access needs.
We'll cover the following...
Multi-Attach in Amazon EBS allows us to attach a single io1 or io2 volume to multiple EC2 instances within the same Availability Zone, enabling high availability and resilience for clustered applications. While we’ve already learned that it’s ideal for systems designed to handle shared storage access like Oracle RAC or distributed databases, let’s now focus on what Multi-Attach offers and how we can configure it effectively.
The primary advantage of Multi-Attach is reducing recovery time and maintaining application continuity. If one EC2 instance fails, another instance already attached to the same EBS volume can instantly take over without additional remounting or reconfiguration.
However, this feature is not a complete solution. Applications must be purpose-built to safely handle simultaneous writes. AWS does not impose locking or conflict resolution; our software stack needs to do that. In production, this typically means using clustering-aware databases, specialized file systems, or external coordination mechanisms.
Multi-Attach for read-only access
A common use case of EBS Multi-Attach is for read-only access to share reference data or static resources. In this example, we’ll look at the step-by-step walkthrough of setting up EBS Multi-Attach for read-only replicas:
Step 1: Create an io2 EBS volume: We’ll start by creating a new io2 EBS volume. This volume will have a size of 100 GB and be provisioned in the
us-east-1aAvailability Zone. We’ll also tag it with the namemulti-attach-demofor easy identification.
aws ec2 create-volume \--volume-type io2 \--size 100 \--availability-zone us-east-1a \--tag-specifications 'ResourceType=volume,Tags=[{Key=Name,Value=multi-attach-demo}]'
Step 2: Attach the volume to multiple instances: We can now attach the volume to multiple instances in the same Availability Zone. We’ll need to run the
attach-volumecommand for each instance we want to connect.
aws ec2 attach-volume \--volume-id <volume_id> \--instance-id <first_instance_id> \--device /dev/sdfaws ec2 attach-volume \--volume-id <volume_id> \--instance-id <second_instance_id> \--device /dev/sdf
Step 3: Mounting the volume: On each EC2 instance, mount the device appropriately. For read-only secondary nodes:
sudo mkdir -p /mnt/sharedsudo mount -o ro /dev/nvme1n1 /mnt/shared
Setting up read-only replicas ensures no accidental writes ...