AWS: Cost optimization — services expenses overview and traffic costs in AWS
Tags: aws, todayilearned, devops
Published: 2021-11-29 11:26:49

---
title: AWS: Cost optimization — services expenses overview and traffic costs in AWS
published: true
date: 2021-11-03 08:08:07 UTC
tags: aws, todayilearned, devops
canonical_url: https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/
---

### AWS: Cost optimization — services expenses overview and traffic costs in AWS

![](https://cdn-images-1.medium.com/max/1024/1*8QppZuMnRQSngTE4H4UqzA.png)

Let’s proceed with our journey on AWS Cost Optimization topics. Previous parts — [AWS: Cost Explorer — costs checking on the CloudWatch Logs example](https://rtfm.co.ua/en/aws-cost-explorer-costs-checking-on-the-cloudwatch-logs-example/) and [AWS: cost optimization — purchasing RDS Reserved Instances](https://rtfm.co.ua/en/draften-aws-optimizaciya-rasxodov-pokupka-i-analiz-rds-reserved-instances/).

One of the shortcomings of the cloud-based architecture is the fact, that it can cost much more than when using own bare-metal servers. With this, cloud providers can have a confusing billing scheme, where you’ll pay for resources used, traffic, and so on.

So, in this post, we will try to understand — for what are paying when using Amazon Web Services, and in the following parts will check useful AWS services to control and optimize AWS environments with Cost Explorer, Trusted Advisor, Compute Optimizer, AWS Budget, etc.

- [Costs categories on AWS](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#Costs_categories_on_AWS)
- [AWS Services payment table](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#AWS_Services_payment_table)
- [AWS Data Transfer Costs](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#AWS_Data_Transfer_Costs)
- [AWS Data Transfers over the Internet](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#AWS_Data_Transfers_over_the_Internet)
- [Inbound traffic from the Internet into AWS](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#Inbound_traffic_from_the_Internet_into_AWS)
- [Outbound traffic from the AWS Cloud to the Internet](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#Outbound_traffic_from_the_AWS_Cloud_to_the_Internet)
- [Data Transfer Costs inside of the AWS Cloud](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#Data_Transfer_Costs_inside_of_the_AWS_Cloud)
- [Inter-Region data transfers](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#Inter-Region_data_transfers)
- [Data transfers between AWS Regions and Direct Connect locations](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#Data_transfers_between_AWS_Regions_and_Direct_Connect_locations)
- [Data transfers between CloudFront Edge locations and AWS Regions](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#Data_transfers_between_CloudFront_Edge_locations_and_AWS_Regions)
- [AWS Data transfer inside on an AWS Region](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#AWS_Data_transfer_inside_on_an_AWS_Region)
- [AWS traffic billing map](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#AWS_traffic_billing_map)
- [AWS traffic advice](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#AWS_traffic_advice)
- [Useful links](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/#Useful_links)

### Costs categories on AWS

All costs can be splitter into three main groups — _Compute_, _Storage,_ and _Data Transfer_:

- **Compute** : charges for the rent of used CPU and RAM capacity, a price depends on a used instance type
- **Storage:** charges for the data stored
- **Data transfer** : in most cases inbound traffic or traffic between services in the same AWS Region is free, but with exclusions. Actually, the traffic costs on AWS will be described in detail in the [AWS Data Transfer Costs](https://rtfm.co.ua/?p=27194#AWS_Data_Transfer_Costs) part of this post UPDATE

And I’d add another category for **Data processing** : this will include charges for HTTP(S) requests and data processing by an AWS service.

Knowing these categories, it will be easy to understand for what do you pay on AWS.

Let’s take a closer look with service examples:

- Compute:
- instance usage time (_EC2, RDS, Redshift_)
- serverless computes _(Lambda_)
- CPU credits usage for T-family instances (the “_T2/T3/Т4 Unlimited mode_”) (_EC2, RDS, Redshift_)
- payment type — On Demand, Spot, Reserved, etc (_EC2, RDS_)
- deployment type — one or multi-availability zones (_RDS_)
- instance type and its CPU and RAM capacity
- Storage:
- Elastic Block Store (EBS):
- a number of read/write operations
- data storage used
- data transfer
- snapshots store (by the S3 price)
- disk type — SSD, HDD
- Simple Store Service (S3):
- storage type (_Standard, Infrequently-Accessed, Glacier_)
- number of objects stored
- Data transfer:
- data sent (_NAT Gateway, LoadBalancer, EC2/EBS, S3_)
- Data processing:
- a volume of received and/or processed data (_Kinesis, CloudWatch Logs)_
- a number of processed HTTP(S) requests(_CloudFront, API Gateway_)

Also, we are charged additional costs for the:

- API requests to the AWS API (CloudWatch metrics collect, CloudTrail events)
- AWS Marketplace licenses
- and additional charges specific for an AWS Service like a number of rules in AWS WAF WebACL, that affects WAF charges, RDS Insights, extended CloudWatch monitoring for EC2, and so on

#### AWS Services payment table

Let’s collect main AWS services to a table to see for what we are paying for when using a Service:

![](https://cdn-images-1.medium.com/max/662/1*JXQJ4mfUNz3LS4MtpvfSmg.png)

### AWS Data Transfer Costs

And let’s discuss the most interesting topic: for what are we paying when sending traffic on AWS?.

As a general rule, traffic on AWS can be divided into two parts — between Amazon Web Services and the Internet, and inside of the AWS network. Also, traffic price can be different depending on its direction — into the same or another Availability Zone, AWS VPC, or an AWS Region.

So, just keep in mind that:

- all outbound traffic will be charged for all services that have an Elastic Network Interface (EC2, ALB)
- all cross-availability zone traffic
- all cross-region traffic

#### AWS Data Transfers over the Internet

#### Inbound traffic from the Internet into AWS

Almost all incoming traffic from the Internet to the AWS Cloud is free of charge.

And vise versa — almost all outbound traffic will cost us some money.

#### Outbound traffic from the AWS Cloud to the Internet

Outgoing traffic from an AWS account to the Internet will be billed by an AWS Region price as they are varied. See the [Amazon EC2 On-Demand Pricing > Data Transfer](https://aws.amazon.com/ec2/pricing/on-demand/) — _Data Transfer IN To Amazon EC2 From Internet_ and _Data Transfer OUT From Amazon EC2 To Internet_.

Also, when AWS will charge you for the outgoing traffic, it will summarize outbound traffic from the following services in your account:

- Amazon RDS
- Amazon Redshift
- Amazon SES
- Amazon SimpleDB
- Amazon EBS
- Amazon S3
- Amazon Glacier
- Amazon SQS
- AWS Storage Gateway
- Amazon SNS
- Amazon DynamoDB
- Amazon CloudWatch Logs

#### Data Transfer Costs inside of the AWS Cloud

#### Inter-Region data transfers

Data transfer between AWS Regions will be charged by the price of the source region. In the same table on the [Amazon EC2 On-Demand Pricing > Data Transfer](https://aws.amazon.com/ec2/pricing/on-demand/) page in the _Data Transfer OUT From Amazon EC2 To_ you can see a price for each region.

For example, we have an S3 bucket in the _us-east-2_, _Ohio_, and it has S3 replication configured to a bucket in the _us-west-1_, _N. California_, see the [AWS: S3 Cross-Region Replication with DeleteMarkers set up](https://rtfm.co.ua/en/aws-s3-cross-region-replication-configuration-and-objects-deletemarkers-replication/) for more details. In that case, we will be charged by the price of the _us-east-2, Ohio_.

#### Data transfers between AWS Regions and Direct Connect locations

Although the main rule is that incoming traffic is free, for the Direct Connet there is an exclusion, as its incoming traffic will be charged, and depends on the source and target region’s prices. See [Data transfer out (DTO) pricing for AWS Direct Connect](https://aws.amazon.com/directconnect/pricing/).

For example, data transfer from Ohio to a Direct Connection in N. California will cost $0.0200 per GB, and from Ohio to Ireland, eu-west-1 — $0.0282 per GB sent.

#### Data transfers between CloudFront Edge locations and AWS Regions

Edge locations for CloudFront are AWS data centers to store information obtained from origins.

Here, we are paying for the:

1. data transfer from Edge locations to the Internet
2. data transfer from Edge locations to origins
3. a number of HTTP(S) requests processed

And again — the price will depend on the source and target region, see more at [Amazon CloudFront Pricing](https://aws.amazon.com/cloudfront/pricing/).

#### AWS Data transfer inside on an AWS Region

When AWS services communicate in the bound of the same AWS Region, some traffic can be charged as well.

- data transfer between Amazon EC2, AWS containers, Amazon RDS, Amazon Redshift, Amazon DynamoDB Accelerator (DAX), Amazon ElastiCache instances, or Elastic Network Interfaces between different Availability Zones, whether it was sent over a public or private IP, or using Elastic IPv4, will cost $0.01 per GB in both directions

For example, we are sending 500 GB from a Redshift cluster in a VPC-1 to an EC2 instance in the same VPC, but neighboring Availability Zone — in that case, we will be charged $5 for the outgoing traffic from the VPC-1, and another $5 for the incoming traffic to the VPC-2.

- data transfer between EC2 instance, containers, or Elastic Network Interfaces in the same Availability Zone VPC using a Public IP or Elastic IP will cost $0.01 per GB in each direction

If you have two EC2, each with its own Elastic IP attached — then we will be charged for the data transfer.

- data transfer between EC2 instances, containers, or Elastic Network Interfaces in the same Availability Zone and the same VPC using private IP is free of charge

Here is simple enough: use only Private IPs inside of a VPC, do not pass the AZ-borders — and you’ll pay nothing.

- data transfer between AWS services that can not be bounded by an Availability Zone or VPC (such as AWS S3, DynamoDB, SES, Kinesis, etc) and EC2 instances or other services in the same AWS Region is free of charge

Also, some cross-AZ traffic is free for services that use multi-AZ deployments, such as Amazon Aurora, Amazon Neptune, and Amazon RDS.

Also, traffic between Classic or Application Load Balancer and EC2 in the same AWS Region is free.

#### AWS traffic billing map

During a lot of googling while writing this post, I didn’t get something similar to a map with an illustrative demonstration on the AWS traffic charges. The only thing I’ve found is the [Overview of Data Transfer Costs for Common Architectures](https://aws.amazon.com/ru/blogs/architecture/overview-of-data-transfer-costs-for-common-architectures/) on AWS Blogs.

So, on the scheme below I’ve tried to demonstrate which traffic will be billed on AWS:

![](https://cdn-images-1.medium.com/max/1024/0*1ocLU9JLUyw65MF8.png)

Let’s check it step-by-step starting from an “entry point” — the Load Balancer in the Region-1 and AZ-1.

**Region-1, Availability Zone-1:**

1. LoadBalencer incoming traffic is charged (because [LCU](https://aws.amazon.com/ru/elasticloadbalancing/faqs/) includes bytes processed)
2. then, the traffic if going from the ALB to an EC2 — and it’s free
3. EC2 sends responses via a NAT Gateway, during this data transfer between this EC2 and NAT GW is free, but NAT GW’s outgoing traffic will be billed
4. EC2 sends data to a CloudFront Edge Location in the same AWS Region, and this is free, but sending data from CloudFront to visitors is billed
5. data traffic from CloudFront Edge Locations to EC2 will be billed
6. data transfer between EC2 and an S3 in the same region is free
7. EC2 via a VPC peering connection talks to an RDS Master instance in the same AZ — and this is also free
8. EC2 via a VPC peering connection talks to an RDS Slave in another AZ — this will be billed (cross-AZ)
9. replication traffic between RDS Master and its RDS Slave in the same AWS Region is free

**Region-1, Availability Zone-2:**

1. data traffic from the EC2 in the AZ-2 to the EC2 in the AZ-1 is charged as it is cross-AZ traffic
2. traffic between EC2 and RDS Slave in the AZ-2 is free
3. but traffic from the EC2 and RDS Master will be billed, as again it’s cross-AZ

**Region-2, Availability Zone-3:**

1. outgoing traffic from the EC2 in this Region to the EC2 in the Region-1 will be billed, as this is the cross-region transfer
2. outgoing traffic from the EC2 in this Region to the S3 bucket in the Region-1 will be billed, as this is the cross-region transfer

#### AWS traffic advice

- try to keep all your workloads in the same AWS Region, and if will need to use another — choose a one with the lowest price
- try to keep all your workload in the same Availability Zone and VPC, and to use private IPs for connections
- avoid using NAT Gateways as it’s billed by the outgoing traffic. Where it’s possible — use Internet Gateways instead
- use CloudFront if you need to send data to users — it will be faster and cheaper in bills than if sending traffic directly from an EC2 instance

### Useful links

- [How AWS Pricing Works](https://d1.awsstatic.com/whitepapers/aws_pricing_overview.pdf)
- [How AWS Pricing WorksOptimize and Save your IT costs](https://aws.amazon.com/ru/aws-cost-management/aws-cost-optimization/?track=costma)
- [How are charges for Amazon EBS volumes calculated on my bill?](https://aws.amazon.com/premiumsupport/knowledge-center/ebs-volume-charges/)
- [Overview of Data Transfer Costs for Common Architectures](https://aws.amazon.com/ru/blogs/architecture/overview-of-data-transfer-costs-for-common-architectures/)
- [The Ultimate Guide to AWS T3 Instances Pricing](https://cloudsoft.io/blog/the-ultimate-guide-to-aws-t3-instances-pricing)
- [Your Comprehensive Guide to Understanding AWS Data Transfer Costs](https://mulupuru.medium.com/your-comprehensive-guide-to-understanding-aws-data-transfer-costs-f5c8241d65ed)
- [AWS Data Transfer Pricing: 7 Ways To Reduce Unexpected Costs](https://www.cloudzero.com/blog/reduce-data-transfer-costs)
- [AWS Application Load Balancer cost estimation](https://cloudsoft.io/blog/aws-alb-cost-estimation)
- [The Guide to AWS Data Transfer Pricing and Saving](https://www.cloudbolt.io/guide-to-aws-cost-optimization/aws-data-transfer-pricing/)
- [Keep costs under control when using t3 instances](https://advancedweb.hu/keep-costs-under-control-when-using-t3-instances/)

_Originally published at_ [_RTFM: Linux, DevOps, and system administration_](https://rtfm.co.ua/en/aws-cost-optimization-services-expenses-overview-and-traffic-costs-in-aws/)_._

* * *