AWS Cross-az流量 [英] AWS cross-az traffic

查看:248
本文介绍了AWS Cross-az流量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两个不同的可用区中有两个实例,需要彼此通信.它们位于vpc专用子网内-

a)当流量彼此通信时,流量会通过NAT吗?
b)如果它们在公共子网中并连接了弹性ip,将会发生什么?
c)如果它们在ec2 classic中使用两个不同的az怎么办?

解决方案

所有这些方案都可以采用两种方式,具体取决于实例之间的寻址方式.

所有VPC实例都具有私有IP地址,即使它们也具有池中的弹性(公共)IP或动态公共IP.

只要A使用B的私有IP地址作为目的地连接到B,流量就不会使用B的公共IP,也不会穿越NAT(当A没有公共IP时),也不会使用A的公共IP或弹性IP(如果有的话).

如果A使用B的公共地址作为目的地连接到B(如果B有一个),那么上一段中的所有语句都将不成立...因此,您几乎总是想使用实例的私有IP连接到另一个实例时.

在EC-Classic中也是如此.

如果实例位于两个不同的VPC中(使用VPC对等连接),您还将为不同可用性区域中的实例之间的数据传输和同一可用区中的数据支付.撰写本文时,收费为每GB $ 0.02.准确地说,在大多数情况下,一个实例发送数据的费用为0.01美元,另一实例接收数据的费用为0.01美元,但这是0.02美元的净额.相反,当实例在两个不同的 region 之间相互通信时,发送实例支付0.02美元,接收实例支付0.00美元...,当然,公共IP总是涉及多重IP的某个层.区域设置.

除非您使用NAT或弹性/公共IP地址,否则您无需为同一AZ(与VPC,如果是VPC)中的实例之间的数据传输付费.性能下降-是不这样做的另一个原因...同样,仅当一个实例未使用私有IP地址作为目标地址连接到另一个实例时,才应该发生这种情况.

i have two instances in two different availability-zones which need to communicate with each other. they are inside vpc private subnets-

a) Will the traffic go through NAT when they talk to each other ?
b) And what will happen if they are in public subnet and have elastic ip attached ?
c) What if they are in ec2 classic in two different az ?

解决方案

All of these scenarios can go either way, depending on how the instances address each other.

All VPC instances have a private IP address, even if they also have an Elastic (public) IP or a dynamic public IP from the pool.

As long as A connects to B using B's private IP address as the destination, the traffic will not use B's public IP, and will not traverse the NAT (when A doesn't have a public IP) and will not use A's public or elastic IP (if it has one).

If A connects to B using B's public address as the destination (if B has one) then none of the statements in the previous paragraph will hold true... So, you almost always want to use the private IP of an instance when connecting to another instance.

That also holds true in EC-Classic.

You will also pay for data transfer between instances in different availability zones, and in the same AZ if the instances are in two different VPCs (using VPC peering). As of this writing, the charge is $0.02/GB. In most cases, to be precise, one instance is charged $0.01 to send the data, and the other is charged $0.01 to receive it, but that's a net of $0.02. Conversely, when instances communicate with each other across two different regions, the sending instance pays $0.02 and the receiving instance pays $0.00... and, of course, public IPs are always involved at some layer of a multi-region setup.

You don't pay for data transfer between instances in the same AZ (and VPC, if VPC) unless you use NAT or elastic/public IP addresses, which -- aside from potential and unnecessary loss of performance -- is another reason not to do that... which, again, should only happen if one instance does not connect to the the other using private IP addresses as the destination address.

这篇关于AWS Cross-az流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆