Calculate AWS Costs in Detail
Calculating AWS costs upfront is a challenge. To get accurate numbers, you have to understand the pricing model of the used AWS services. A pricing model consists of one or many pricing dimensions. E.g., GBs stored, number of requests, etc. Keep in mind that each service is different. EC2 instances are billed based on how long they run, how much storage you provision, and how much traffic they receive and send (some traffic is free). The pricing dimensions of an S3 bucket are stored data, number of requests, number of tags, and many more. After you understand the pricing model, you have to come up with the numbers. How much traffic does your application process? How many requests to S3 do you plan to make? The second step is usually the more challenging part. In this blog post, I share the tools and techniques I use to calculate AWS costs.
To calculate costs, you need a detailed understanding of the architecture. What AWS services are used? How are the services used? What communication paths exist? What data is processed and stored? What are data retention policies? And many more questions.
I usually start by looking at the architecture diagram. I recommend diving as deep as possible to understand what’s going on. VPC Flow Logs can be helpful to understand communication paths. IAM policies provide a hint of what APIs are called.
Once you know what AWS services are used, you can familiarize yourself with the pricing models of each service.
Each AWS service has a pricing page. I recommend you to read them from top to bottom. There are no shortcuts if you need an accurate cost calculation. Check out the following pricing pages to get a sense of the differences between services:
Keep in mind that prices are likely different in each AWS region!
Once you understand the pricing dimensions, you have to estimate the usage for each of the dimensions. Some dimensions are straightforward to guess. Others are more tricky. Let me provide you two examples.
A CloudWath dashboard is priced at $3 / month. I know that I create one dashboard, so it is easy to estimate the costs.
CloudWatch Logs are priced based on the data volume you ingest and the data volume you store. The problem: How much log data does your application produce? The log volume likely correlates with the number of requests the application processes. I recommend running an experiment to get a better understanding of the usage pattern:
Please support our work!
We have published 327 articles, 42 podcast episodes, and 15 videos. It's all free and means a lot of work in our spare time.
If you value the work we do, you should support us. With your help, we can spend enough time to keep publishing great content in the future. We look forward to sharing our AWS knowledge with you.Support us
- Set up your application.
- Take a note of the
storedBytesvalue of the log group.
xnumber of requests through the system. If you are lucky, you can reuse a load test that you already have. Make sure that
xis large enough (e.g., 100,000 requests).
- Take a note of the
- Calculate the difference between the two
storedBytesvalues and divide them by
AWS provides tools to help us with cost calculations. the Pricing Calculator is the new kid on the block. The Simple Monthly Calculator is the older version you might need to fall back to. Both tools miss services and pricing dimensions! I highly recommend not skipping the Understanding the pricing models step to avoid surprises.
I use the AWS tools to come up with rough estimates only. If I need detailed calculations, I create a spreadsheet. I believe you need a spreadsheet anyway because you usually need to calculate the pricing dimension usage to enter into the tools.
I prefer to use a “business” metric as a starting point, such as daily active users or the number of files uploaded. Based on this number, I can calculate the pricing dimension usage. The screenshot shows a real-world calculation of mine:
I see many calculations miss an important aspect: traffic. Traffic costs are very tricky:
- Traffic from the Internet to EC2 is free.
- Traffic from EC2 to the Internet is billed.
- Traffic between EC2 instances in the same AZ is free.
- Traffic between EC2 instances in different AZs/regions is billed.
- Traffic between EC2 and RDS is free.
- Traffic between EC2 and MSK (Kafka) is billed.
I usually think about traffic costs this way: I assume all traffic is billed. I check the pricing pages to find the traffic costs. In some cases, you will find that traffic is free.
In the following video, I share my workflow in more details based on a real-world example:
Calculating AWS costs is tricky. I recommend following these steps:
- Understand the architecture
- Research pricing models of used AWS services
- Estimate price dimension usage
Creating an accurate calculation for a medium complex architecture can take a working day.