Skip to content

Data Transfer Costs Between ALB and EC2 Instance (and Vice Versa)

0

Hi everyone,

I have two EC2 instances (Instance A and Instance B) in the same VPC, same AZ, and same public subnet, along with a public ALB and an Internet Gateway.

Instance A is running a Java Spring app that sends requests to a microservice running on Instance B via an API endpoint (e.g. https://messaging.mycompany.net.au). An A record is configured to point this domain to the public DNS of the ALB, and Instance B is sitting behind the public ALB. Additionally, my clients can also send requests to Instance B (a different app) through the same ALB.

From what I understand, AWS charges $0.09/GB for data transfer from the ALB to internet users and $0.02/GB for data transfer from the ALB to Instance A in my scenario.

In AWS Cost Explorer, I filtered by the "Elastic Load Balancing" service and the "APS2-DataTransfer-Out-Byte" usage type, but I'm not sure whether this includes traffic between the ALB and Instance A or only ALB traffic to external users. How can I specifically find out the data transfer costs for traffic from Instance A to the ALB and from the ALB to Instance A?

Thank you in advance for any guidance!

3 Answers
0

Based on your setup, I'll clarify the data transfer charges that apply in your scenario.

First, since both EC2 instances (A and B) are in the same Availability Zone (AZ), data transfer between them would normally be free if they communicated directly. However, your setup routes traffic through the ALB using its public DNS, which changes the cost structure.

When Instance A communicates with Instance B through the public ALB:

  1. The traffic goes from Instance A to the ALB, then from the ALB to Instance B
  2. Since Instance A is using the public DNS of the ALB (even though everything is in the same VPC), the traffic is effectively going through the Internet Gateway and back into your VPC
  3. This creates an additional charge of $0.01/GB in each direction

For the specific usage type you mentioned (APS2-DataTransfer-Out-Bytes), this represents data transfer from the Asia Pacific (Sydney) region to the internet. This would include traffic from your ALB to external clients, but not the internal traffic between your ALB and EC2 instances within the same region.

To identify the data transfer costs between your instances and the ALB, you should look for usage types that include "Regional" in their name, such as "APS2-DataTransfer-Regional-Bytes", which would capture the inter-AZ or intra-region data transfer charges.

Note that AWS provides 100 GB of free data transfer out to the internet each month (aggregated across all AWS services and regions, except China and GovCloud).

To optimize costs, you could consider:

  1. Having Instance A communicate directly with Instance B using private IP addresses
  2. Using an internal ALB instead of a public one for internal communications
  3. If you need to maintain the current architecture, monitor your data transfer costs closely using AWS Cost Explorer with the appropriate usage type filters
    Sources
    Can someone explain data transfer charges in detail? | AWS re:Post
    Understanding data transfer charges - AWS Data Exports
    Community | Optimizing Network Traffic and Cost in AWS During Migration
    Data Transfer Charges | AWS re:Post
    Exploring Data Transfer Costs for AWS Network Load Balancers | Networking & Content Delivery
answered 2 months ago
EXPERT
reviewed 2 months ago
  • In my scenario, is "APS2-DataTransfer-Regional-Bytes" billed under EC2 or ELB for the traffic between ALB and EC2? Thank you.

0

Since you're using an ALB with all resources in the same AZ, internal traffic between Instance A and the ALB should not incur cross-AZ charges. However, traffic from the ALB to external internet users will incur outbound data transfer charges

You can use the Tag filter in Cost Explorer to visualize cost and usage by tag according to your tagging strategy. For example, if you've tagged resources with a "Project" tag, you can filter by project in Cost Explorer to see the total cost of that project across multiple AWS services. Similarly, you can filter by team, environment, cost center, or any other custom tag you've defined.

Ref: https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html

That said, what you can try is:

Apply Region Filter: First, filter by Region and select Asia Pacific (Sydney). This narrows your view to all costs associated with resources in that region.

Apply Usage Type Filter: Next, add a Usage Type filter specifically for "APS2-DataTransfer-Out-Bytes" to isolate outbound data transfer to the internet. This ensures you're only viewing charges for data leaving AWS to external destinations, not internal traffic.

Add Tag Filters: If you want to further segment this by specific resources, apply your tag filters on top of these dimension filters. When applying a tag filter, Cost Explorer displays charges only for resources tagged with the selected tag values.

Some extra considerations:

  • After you create and attach tags to resources, they appear in the AWS Billing Console's Cost Allocation Tags section within 24 hours. You must then activate these tags for AWS to start tracking them.
  • After activation, it can take up to 24 hours for tags to appear in Cost Explorer and become fully available for filtering and grouping.
  • Cost allocation tags do not apply retroactively to historical data by default. Tags only track costs from the time they are activated forward.
AWS
answered 2 months ago
0

APS2-DataTransfer-Out-Byte refers to cross-AZ charges within the same region (ap-southeast-2 in this case). There will be charges from ALB to EC2 if the traffic is going cross AZ. If you have other resources like RDS, ECS, it will include those cross-AZ charges as well. You might get specific details from cost utilisation report (CUR).

Also, if you want to remove cross AZ charges for ALB, you can go to Load Balancer > Attributes -> Availability Zone routing configuration > Cross-zone load balancing and turn this setting to off.

Refer: https://docs.aws.amazon.com/cur/latest/userguide/cur-data-transfers-charges.html#data-transfer-within-region

EXPERT
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.