AWS Cloud Operations Blog

Using AWS Cost Explorer to analyze data transfer costs

AWS Cost Explorer helps you manage your AWS costs by giving you detailed insights into the line items in your bill. In Cost Explorer, you can visualize daily, monthly, and forecasted spend by combining an array of available filters. Filters allow you to narrow down costs according to AWS service type, linked accounts, and tags. You can uniquely tag your AWS services. For example, you can tag Amazon EC2 instances in Amazon Elastic Compute Cloud (EC2), or you can tag Application Load Balancers in the Elastic Load Balancing service.

In this blog post, we’ll discuss how to analyze data transfer costs using Cost Explorer. Data transfer charges are incurred when data is transferred out from AWS services to the Internet, or between AWS regions or Availability Zones. When EC2 instances are behind a load balancer, it becomes difficult to narrow down the cost of the data transfer or to understand the cost associated with Internet outbound, inter-Availability Zone or inter-Region data transfers, as well as which environment these costs occurred in.

Setting up cost allocation tags

Before you set up cost allocation tags, categorize your instances. In the example in this blog post, we’ll use either production or development, but you can tag them in whatever way makes sense for your business. To do this, go to your Amazon EC2 console, and, for each instance, create a tag (if it wasn’t  already created at the time of instance creation) with Key=Environment and  Value=Production or Development.

EC2 Instances that are launched dynamically as part of an Auto Scaling group can be tagged as described here.

Choose Load Balancers in the left navigation pane, and create an Environment tag for each load balancer in the same way.

After you tag your EC2 Instance and your load balancer, the next step is to activate the cost allocation tags as follows:

1. Sign in to your Billing and Cost Management console at https://console.aws.amazon.com/billing/home?#/.

2. In the navigation pane, choose Cost Allocation Tags.

3. Select the Environment tag and choose Activate.

Note: It might take up to 24 hours for the tags to gather costs associated with the AWS service.

Using filters to analyze data transfer costs

After your cost allocation tags have been activated, and your workloads have run for at least a day, you can use filters in Cost Explorer to analyze your costs over that period.

1. Sign in to AWS Cost Explorer at https://console.aws.amazon.com/cost-reports/home?#/

2. Choose Explore in the navigation pane, and then choose Cost and Usage.

3. Choose the date range for the period for which you want to see the costs, and choose the Apply button.

 

 

 

 

 

 

 

 

 

 

 

 

4. Choose Filters – Service, then EC2-instances, and then EC2-ELB.Next choose Apply filters.

 

 

 

 

 

 

 

 

 

 

 

5. To see the total EC2 data transfer cost:

Choose Filters, Usage Type Group, EC2: Data Transfer – inter-Availability Zone, Internet (Out), and Region to Region (Out), then choose Apply filters.

You can also choose each individual data transfer type by checking only the box for that type.

 

 

 

 

 

 

 

 

 

 

 

 

6. Next, choose Filters – Tag, then choose the tags that you want to see, and choose Apply filters. In this case we’ll choose Development and Production.

 

 

 

 

 

 

 

 

 

 

7. Choose Apply filters to see the total data transfer costs for all EC2 instances and load balancers.

Grouping

  1. To view the costs broken down by environment, choose Tag in the Group By menu, and then choose Environment. This shows both a graph and a line-item summary of the data transfer costs for each of your environments.

2. Choose Download CSV to save and share the results.

Reducing Data Transfer Costs

If data transfer from EC2 to the public internet shows up as a significant cost, consider using Amazon CloudFront. Any image, video, or static web content can be cached at AWS edge locations worldwide, using the Amazon CloudFront Content Delivery Network (CDN).

Here are some other ways to reduce the data transfer cost based on specific scenarios.

  1. You can architect your solution to avoid inter-Region data transfer costs. For example, accessing the data from Amazon S3 via Amazon EC2 within the same region is free of charge, whereas accessing Amazon S3 data from a different region incurs a cost.
  2. Also, be aware of inter-Availability Zones data transfer charges between Amazon EC2 instances, even within the same region. If possible, the instances in a development or test environment that need to communicate with each other should be co-located within the same Availability Zone to avoid data transfer charges. (This doesn’t apply to production workloads which will most likely need to span multiple Availability Zones for high availability.)
  3. You can avoid using public IP addresses for internal data transfers within the same Availability Zone. Intra-Availability Zone data transfers are free, provided you use private IP addresses
  4. If you have resources in different regions or multiple accounts then using VPC Peering or VPC Sharing can further help you to optimize the data transfer cost.

Conclusion
In this blog post, we have shown you how to visualize and understand costs associated with different data transfer types within your AWS environment. We explained how to apply and activate your tags for your AWS resources. Then we showed you how to use tags as filters within Cost Explorer. We also demonstrated how to combine different filters and create a narrowed down cost report which can provide further insights into the charges. You can modify this example and use filters that are suitable for your individual use cases.

About the authors

 

 

Ashish Mehra is a Solutions Architect at AWS. He is a Serverless, IoT and Containers enthusiast and loves helping customers design secure, reliable and cost-effective solutions on AWS.

 

 

 

Rana Dutt is a Senior Solutions Architect at AWS. He is a containers enthusiast and enjoys helping customers implement cost-effective microservices architectures that scale.

 

 

 

Belle Guttman manages a team of Solutions Architects. She works with startups and small businesses to help them adopt the cloud in the most scalable, secure and cost-effective ways.