There are quite a few storage options within AWS and they have changed over the years. EBS volumes are centerpiece of mountable storage. There are several different volume types depending on what you want to accomplish, but the two most common ones are general purpose and provisioned IOPS (input/output per second). When considering storage on AWS there are a few things to keep in mind. Larger general purpose volumes get more IOPS but there is a limit to this and eventually you'll need to switch to provisioned IOPS which is not always tractable because it can be expensive. Larger instance types inherit better network performance but you'll need to stop the instance to increase it's size. The upside to EBS though is that you can change the storage type without stopping the attached instance. This is done through the modification command and is a pretty seamless. Similarly, you can increase IOPS in this way. There are many configurations you can make in terms of storage but one that is often discussed but rarely demonstrated is RAID. In this post I'll actually show you how to attach two EBS volumes to a running instance, RAID them together, install a file system and mount it. All of this can be done without stopping the instance. Interested? Keep reading.
Storage is generally a broad topic and there is much to be said about RAID configurations. However, my intent here is to show you how to leverage your RAID knowledge on AWS. Our goal is to RAID via striping to increase performance. You'll probably recognize this as RAID0. This article won't dive into parity or deeper topics regarding RAID but will show you some actual mechanics of what is possible as well as the consequences like possible service interruptions.
Let's Try It
Assuming you have a running instance you can create two 10Gib volumes to attach and RAID together. Here is what it looks like.
Most AWS users don't dwell EBS so much because their mind just defaults to S3 where storage is usually concerned. Their are many important use cases for EBS so it's ideal to be aware of what is possible. Be careful to create your volumes in the same availability zone as your running instance or you will not be able to to attach them. This is a common oversight. Notice that my instance-id resolves while attaching because I have them the volume and in the instance in the same availability zone. One strategy to keep track of things is to use resource groups and tag everything. This will keep you organized and prevent sad mishaps in the future.
Once both volumes are attached you see them by running
lsblk from the command line. Now you can see the two volumes attached and ready to be RAIDED to a 20Gib volume. Let's see how we can do it.
Go for Speed
yum install mdadm to prepare for RAIDing.
We are going to use the tool to RAID for performance. The command looks exotic but once you wrap your mind around the syntax it will feel pretty simple
sudo mdadm --create --verbose /dev/md0 --level=0 --name=sequoia-raid --raid-devices=2 /dev/xvdf /dev/xvdg
Once we have RAIDED them together we can install a file system.
sudo mkfs.xfs -L sequoia /dev/md0
Then you can mount the new volume with the command.
sudo mount /dev/md0 /mnt
df -h you'll see your fully mounted 20Gib volume ready to be written to.
The Value of Experience
There is limitless value in getting your hands dirty and see what you can do. This will encourage new ideas to develop in your mind and through previous experience you'll understand the pros and cons of your decisions. There are a lot of innocuous services in AWS but by considering why they were invented you can get a cohesive image of their ideal uses.