Every AWS EC2 instance you provision needs storage to serve as the primary drive. Like everything else in AWS, your usage of this is metered, and can dramatically change the cost of EC2.
Storage Costs Money
The size of your initial volume will vary depending on your server’s type, but you can provision anywhere from a few GB to 16 TB per volume. You can provision multiple volumes to attach to a single instance, and you can swap volumes between instances. There’s also AWS Elastic File System (EFS), which is a volume you can share between multiple instances, though it’s a separate service from EBS.
Your use of this storage is metered based on how much you provision (not how much is actually stored), and you’ll be charged per second of use. This cost is added to the cost of the EC2 server itself, and can be quite confusing when your bill comes back higher than you expected.
The going rate for general purpose SSD storage (gp2) is $0.10 per GB, per month. If you rented a terabyte of storage, you’d be charged $100 every month. It’s metered down to the second, so if you only rented the volume for a day, you’d be charged $3.20 for that day.
Because of this, you shouldn’t use EBS for storing huge amounts of data; S3 is much cheaper for that use case. EBS is intended to be fast storage that is positioned very close to the EC2 instance (and even on-device with Instance Storage), and is used as a boot volume for EC2 instances.
The Different Types of EBS Volumes
General purpose SSD (gp2) is the default for new instances. It costs $0.10 per GB-month, which is over four times the price of S3 storage. But, it’s a bootable SSD designed for use with EC2, and is much faster than S3 storage.
Provisioned IOPS SSDs (io1) are AWS’s high performance SSDs. They’re built to reach speeds up to 1024 MB/s, and are priced to suit. The base cost for storage is $0.125 per GB-month, which is a 25% increase from gp2. But, you’re also charged based on how fast you want to access them. If you need to make use of the full 1024 MB/s pipe, you’re going to have to pay more.
You may not need a provisioned IOPS SSD. You can easily switch a volume between the two tiers, so should test your application with gp2 first to see if it meets your needs. You can use AWS CloudWatch for this test, which will monitor your instance and provide statistics for you to base your purchasing decisions on.
The metric you’re looking for, in this case, is the VolumeQueueLength of the EBS volume. This measures how many pending operations the volume is waiting to fulfill. If this graph is spiking up, you’re likely maxing out your EBS volume, and should consider upgrading to provisioned IOPS storage.
You can also look at your EC2’s IOWait, which measures how many CPU cycles are spent waiting for read or write operations.
If you don’t need speed, you can also use hard drive-based EBS volumes for your instances. You can’t boot off of these drives, so you’ll still need a small gp2 drive to serve as the boot drive. There are two tiers of HDD based volumes:
- Throughput Optimized HDD (st1): a general purpose HDD volume, optimized for throughput rather than quick reads and writes. This tier costs $0.045 per GB-month, less than half the price of gp2.
- Cold HDD (sc1): slower than st1, but cheaper at only $0.025 per GB-month.
Whichever type of volume you choose, if you decide to back the volume up using S3 snapshots, you’ll be charged $0.05 per GB-month for S3 data. These are incremental snapshots, meaning every change you make will be stored, and no data is duplicated. But if you’re often changing the data on disk, over time the snapshot can grow in size to be bigger than your initial volume.
Use the AWS Calculator
AWS provides a calculator for determining what your monthly bill will be based off of your usage. You should always use it before provisioning anything to prevent unforeseen charges.
Load up the calculator, and enter in which services you’d like to provision. The calculator supports most AWS services, and will total everything together into one monthly bill.
Another useful feature AWS provides is the AWS Cost Explorer. This management panel will break down your past charges by type, and show you how much AWS is really costing you.
You can access this panel here, or from your billing dashboard in the AWS console. In the explorer, you can break down your past charges by service, instance type, and region, and look at how much everything is costing you per month.
AWS provides a simple breakdown in your actual bill every month, but it’s easier to visualize the costs using the explorer, especially if you make use of many AWS services.