How to calculate Amazon EBS I/O costs on Linux

I recently moved a client’s database from S3-backed storage to an EBS volume. The client’s database had a heavy read/write load on it, so they wanted to know how much additional costs would be incurred by the move to EBS.

Currently, Amazon prices EBS volumes as:

$0.10 per GB-month of provisioned storage
$0.10 per 1 million I/O requests

So let’s say the database takes up 100 GB of space. That will cost them only $10 a month.

But how do you figure out the costs of the I/O requests? Turns out it’s not too difficult on Linux.

First, view your disk stats and find the drive which your database current resides on (in this example, it will be on sdh):

$ cat /proc/diskstats

sdh 123241141 1835 8055865321 1587962870 996307889 722821165 23591028861 1809891504 1 1720770520 3397713604

To get the total number of read and writes on the disk, add the first and fifth numbers together.

So in this example, we add 123241141 + 996307889 to get the total read/writes.

Next, we’ll need to know how many days the system has been up for:

$ uptime
10:00:0 up 100 days, 20:11, 1 user, load average: 0.50, 0.50, 0.50

Now the formula to estimate your EBS I/O costs will be:

Cost = [$0.10 * 30 days * ((first number) + (fifth number) / (days of uptime))] / 1 Million IO Requests

So from our example, the calculation will be:

0.10 * 30 * [(123241141 + 996307889) / 100] = 33586470.9
33586470.9 / 1 Million IO Requests = 33.5864709

So our monthly EBS IO request cost wil be approximately $33.58 when the database is moved to EBS!

Credit goes to Brian Ghidinelli for figuring this out!

AWS Consulting

Casey Labs provides AWS consulting for growing companies, helping them to build secure server infrastructure in the cloud.

Contact us today: [email protected]