0

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.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
tzwickl
  • 1,341
  • 2
  • 15
  • 31
  • Hmm, where are computing the costs. The aws simple calculator at https://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 Jun 15 '16 at 03:58
  • @Shibashis So you suggest that those network-in costs occur because of the fact that I'm using EIP? – tzwickl Jun 15 '16 at 10:59
  • Yes. U will have always have such a cost for data coming in into a public endpt – Shibashis Jun 15 '16 at 11:57

2 Answers2

4

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.

Community
  • 1
  • 1
Michael - sqlbot
  • 169,571
  • 25
  • 353
  • 427
  • But I'm exclusively using private IPs for communication between the VMs inside the same availability zone. – tzwickl Jun 15 '16 at 10:37
  • +1 for the hostname tip. I wasn't unsure if the Public IPv4 DNS (as AWS calls it) would be resolved to the private IP when queried from within the VPC, which it does. – Slav Apr 12 '23 at 14:35
1

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.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Heh, looks like this question got good coverage. I should type faster. :/ – Michael - sqlbot Jun 15 '16 at 04:24
  • Yes I already checked everything and they are all using private IP addresses for communication between each other and they are all in the same availability zone. The only public IP address in use is for the communication between the Load Test Driver to the VM1. – tzwickl Jun 15 '16 at 10:42