When you’re looking at the options for cloud computing, one of the first things you’ll want to do is figure out what the price of EC2 is. Amazon offers a wide variety of services, including EC2, so it’s important to understand how these prices work.
EC2 is Amazon’s way of pricing its cloud services. It charges different prices for different types of resources used in running an EC2 instance: CPU, memory, and storage.
The most common type of resource used in running an EC2 instance is CPU. For example, if you’re using a Xeon processor with 2 cores and 8GB of memory, Amazon will charge you $8 per hour for that instance. If you’re using a Xeon processor with 4 cores and 16GB of memory, Amazon will charge you $24 per hour for that instance.
If you’re using a Xeon processor with 2 cores and 8GB of memory and a 1TB hard drive, Amazon will charge you $0.50 per hour for that instance. If you’re using a Xeon processor with 4 cores and 16GB of memory and a 2TB hard drive, Amazon will charge you $1.25 per hour for that instance.
The next most common type of resource used in running an EC2 instance is memory. For example, if your CPU has 1GB of RAM and your hard drive has 10TB capacity, Amazon will charge you $8 per hour for that instance (assuming your CPU has 1GB). If your CPU has 4GB of RAM and your hard drive has 20TB capacity, Amazon will charge you $24 per hour (assuming your CPU has 4GB).
If your CPU has 1GB of RAM and your hard drive doesn’t have 10TB capacity but does have 500TB capacity or more, Amazon will not charge you anything for that resource use (assuming your CPU doesn’t have 1 GB). Instead it’ll just give away
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.