DEV Community

Cover image for [SAA-C03: Part 4] - Unlocking EC2 Storage: Mastering EBS, AMIs, and Beyond for Optimal Performance
Mukhil Padmanabhan
Mukhil Padmanabhan

Posted on

[SAA-C03: Part 4] - Unlocking EC2 Storage: Mastering EBS, AMIs, and Beyond for Optimal Performance

When you use AWS EC2 instances, you need to store your data. Fortunately, AWS provides various storage options, all designed for different workloads. In this article, we’ll go through the EC2 storage options, demystify them and simplify it so you can decide which one fits best your projects.


EBS (Elastic Block Store): Your Cloud-Based Hard Drive

Imagine your EC2 instance is a Laptop, and like any laptop, it needs a Hard drive to store your files, apps, and data. In AWS EBS ( Elastic Block Store ) is your cloud-based hard drive. But an EBS Volume (hard drive) more or less functions like a removable USB stick, you plug it into one EC2 instance store your data if needed remove and plug it into another EC2 instance the data is still there even if the instances are powered off.

Key Features of EBS:

  • Persistence – Data sticks around after you turn off your EC2 instance. It’s not like RAM that forgets everything when the power goes out; it’s persistent storage.
  • Flexibility – You can resize your EBS volume (grow or shrink it) and change its performance (I/O) characteristics as needed.
  • Availability: EBS volumes are specific to a particular availability zone only. Like if you create in us-east-1a then it can be use there only, until you take snapshot and move it.

Snapshots: Saving Your Work for Later

You can think of EBS Snapshots as a photograph you take of your hard drive at a given time. It takes an image of everything on your EBS volume, and you can use it to restore that data in the future—even if you want to do so in another availability zone. Think about how you might save a backup of all the files on your laptop's hard drive so that if anything ever happened to your laptop, you could replicate your setup on a different machine without losing any work in the process.

With snapshots, you can even archive them for long-term, lower-cost storage, or protect them from accidental deletion using a Recycle Bin feature.


AMI (Amazon Machine Image): Pre-Packing Your Machine

Think if every time you had to setup a new laptop, you could pre-configure and include your operating system, apps and settings in a template. That’s what AMI (Amazon Machine Image) does. AMI is like pre-configured blueprint for your EC2 instances. It will save you from the burden of installing software manually each time when launching new instances.

AWS comes with many pre-built AMIs but if you need something else, you can create your own custom AMI, based on specific needs. For example if you have customized an EC2 instance and installed all the software that you like, then packing it into an AMI and deploying the same setup in other places is quite straight forward.


EFS (Elastic File System): Sharing Files Across Instances

Did you ever use a shared folder in your office, or in Google Drive where multiple people can access and edit files at the same time? That’s what Amazon EFS (Elastic File System) does but for EC2 instances. It is shared storage space which many instances can access at the same time however they are located on a different place (availability zones).

Imagine you need to run multiple servers for your website, and all of them must have access to the same data files. EFS is there to ease that burden. You can set up a centralised storage system where all servers are able to read and write files without having to perform any data duplication across every instance. It’s highly available, scales automatically, and works well with use cases like content management systems or data sharing between multiple EC2 instances.

Downside? It’s more expensive compared to EBS. But if you need shared storage — it’s definitely worth it.


EBS Volume Types: Finding the Right Fit

There are many different types of EBS to choose from depending on your needs. It’s like deciding if you want a standard hard drive or a super fast SSD for your laptop.

  • General Purpose (gp2/gp3): Think- you are using a laptop of medium price range which is pretty fast to perform regular day to day activities like browsing, editing any document and playing videos. Exactly that gp2/gp3 is; It’s the best suitable option for general use cases like web servers or application hosting.
  • Provisioned IOPS (io1/io2): Think- You are trying to work on a 4K video or running some super-heavy software, where you need really high performance, in that case do you think medium required write speed will work? Need something with very high read/write speed? That io1/io2 does; good for applications like large databases where you need really very fast and constant/tight throughput performance.
  • Throughput Optimized HDD (st1): If you’re familiar with the big, heavy external hard drives often used for backups or just to store large things that you don’t access often but when you need it you want to move it fast, this is the best analogy for st1. It’s best suited for things like big data analytics or when you’ll be working on a lot of data all at once.
  • Cold HDD (sc1): If you think of those same big, heavy external drives that maybe get touched once every few years where you keep old photos or something else of sentimental value, that’s sc1. The lowest cost backed storage option if you rarely ever plan on accessing your data.

Multi-Attach EBS: Sharing Storage Among Multiple Instances

An EBS volume is generally like a single hard drive that’s attached to one computer (or EC2 instance). But what if you want multiple computers to be able to use the same hard drive at the same time? That’s where Multi-Attach EBS comes in.

Like if you’re running a database cluster where many servers need to be able to talk to each other fast because they get a ton of requests. You want all those servers to be reading and writing the same data, and if one of them goes down you don’t want your entire website going offline. Multi-Attach EBS works for that, but only with the io1/io2 high-performance SSDs.

Let’s say you’ve got 3 servers working together to store and retrieve customer data for some kind of online shopping website. With Multi-Attach all 3 of those servers can access the same data concurrently which means your site can read or write that data much more quickly (same as above).


Wrapping Up: Choosing the Right Storage for Your EC2 Instances

With AWS you have the flexibility to choose right storage type as per your use case:

  • Use EBS for stable, persistent storage.
  • Use Snapshots to save and restore your data.
  • Create and launch EC2 instances with AMIs you build and manage.
  • Use EC2 Instance Store for short term, high IOPS storage.
  • Choose EFS if you have a need for shared file storage across multiple instances.
  • And consider the different EBS volume types based on your price and performance expectations.

So that’s it for now! I hope you understood everything clearly on EC2 storage options. Stay tuned and happy learning!

Top comments (0)