0
votes

I'm new to AWS EC2 and I'm conduction some experiments for my Thesis. I want to predict the costs based on simulations and in order to verify my results I set up the following scenario with three EC2 instances and one Load Test Driver: EC2_setup

I let the experiment run for two days and evaluated the costs with the help of the AWS cost reporter. One thing I don't understand so far are the costs for the PublicIP-in. When I look at the Amazon EC2 Pricing there are no costs for data transfer IN to Amazon EC2 From the Internet, but still I get accounted costs for PublicIP-in. Also when looking at the Amazon Cost Calculator no costs for data transfer in are listed.

data_transfer_costs

I would really appreciate if someone could explain to me where those data transfer in costs come from. Thanks in advance for your help.

2
Hmm, where are computing the costs. The aws simple calculator at calculator.s3.amazonaws.com/index.html has a field for entering your network-in estimates for computation of total costs. Also since you have EIP, which receives some kind of traffic, the charging looks appropriate. - Shibashis
@Shibashis So you suggest that those network-in costs occur because of the fact that I'm using EIP? - tzwickl
Yes. U will have always have such a cost for data coming in into a public endpt - Shibashis

2 Answers

3
votes

Data Transfer IN To Amazon EC2 From

Amazon EC2 [ ... ] in the same Availability Zone

Using a private IP address $0.00 per GB

Using a public or Elastic IP address $0.01 per GB

Your instance is talking to itself, using its public IP address, instead of its private IP address.

Or, if the instance with the public IP address is also performing NAT for the other two, one of them may be using its public IP address to access it.

EC2 instances are not aware, at the OS layer, of their public IP address, so in either of these cases, the traffic would leave the instance, hairpin through the Internet Gateway, and return to the instance thus using more resources, and hence the additional charge.

If you have a DNS hostname pointing to that public IP address with an A-record, and that's driving this traffic, there's an easy fix.

Do an nslookup of the public IP. Take the hostname you get (it will be in the form of ec2-x-x-x-x.cc-region-n.compute.amazonaws.com) and point your DNS to that hostname as a CNAME.

There's magic in the network infrastructure that will cause this to resolve to the public IP if queried globally, but to the private IP if queried within your VPC, if the VPC's DNS settings are enabled.

Otherwise, be certain the instances are assessing each other private IP addresses exclusively and this charge should not accrue.

1
votes

The Amazon EC2 pricing page includes these costs:

Data Transfer IN To Amazon EC2 From:

Amazon EC2, Amazon RDS, Amazon Redshift and Amazon ElastiCache instances or Elastic Network Interfaces in the same Availability Zone...Using a public or Elastic IP address: $0.01 per GB

Amazon EC2, Amazon RDS, Amazon Redshift and Amazon ElastiCache instances or Elastic Network Interfaces in another Availability Zone or peered VPC in the same AWS Region: $0.01 per GB

So, the PublicIP-In charge might be due to:

  • Traffic from the same Availability Zone going to the Elastic IP address (effectively going 'out' to the Internet but then straight back 'in'), or
  • Traffic between Availability Zones

Check that all your servers are in the same Availability Zone and that they only refer to each other via their Private IP address.