Sub topic 8
Reducing inter-AZ traffic
This chapter assumes you know how Availability Zones (AZs) and subnets relate, and that traffic between AZs in one region over private IPs is billed. AWS charges $0.01 per GB in each direction, so a round trip costs about $0.02 per GB. Check current prices for your region. The cost is small per request but grows quickly with chatty services.
Where inter-AZ traffic comes from
Most inter-AZ traffic comes from defaults that spread requests evenly, not from deliberate design:
- Load balancers that send requests to targets in every AZ.
- Kubernetes Services that pick any pod endpoint in the cluster.
- Clients that connect to a database primary or cache node in another AZ.
- Streaming systems such as Kafka, where consumers read from a partition leader in another AZ.
In Cost Explorer, this spend appears under usage types ending in DataTransfer-Regional-Bytes. Use the grouping from the earlier chapter to size it before you change anything.
Load balancers and cross-zone behavior
Cross-zone load balancing lets each load balancer node send traffic to targets in all AZs. It improves balance but can create inter-AZ traffic.
| Load balancer | Cross-zone default | Inter-AZ data charge when cross-zone is on |
|---|---|---|
| Application Load Balancer | On | No |
| Network Load Balancer | Off | Yes |
| Gateway Load Balancer | Off | Yes |
For a Network Load Balancer, leaving cross-zone off keeps traffic in the AZ where it arrived. Do this only if each AZ has enough targets to absorb its share of load.
aws elbv2 modify-load-balancer-attributes \
--load-balancer-arn arn:aws:elasticloadbalancing:us-east-1:111122223333:loadbalancer/net/my-nlb/0123456789abcdef \
--attributes Key=load_balancing.cross_zone.enabled,Value=falseZone-aware routing in Kubernetes
On Amazon EKS, a Service sends traffic to any ready pod by default. Topology Aware Routing asks kube-proxy to prefer endpoints in the caller's zone.
apiVersion: v1
kind: Service
metadata:
name: orders
annotations:
service.kubernetes.io/topology-mode: Auto
spec:
selector:
app: orders
ports:
- port: 80
targetPort: 8080The control plane applies zone hints only when endpoints are spread roughly evenly across zones. If one zone has too few pods, Kubernetes drops the hints and routes cluster-wide again. Spread pods with topologySpreadConstraints on topology.kubernetes.io/zone so the hints stay active.
Data stores and streaming
- Kafka and Amazon MSK: Set
client.rackon consumers to the AZ ID, and enable follower fetching on the brokers. Consumers then read from a replica in their own AZ. - Read replicas and caches: Point each application instance at a replica or cache node in its own AZ where the consistency model allows it. Writes still go to the primary.
- Chatty service pairs: If two services exchange large payloads on every request, deploy them together in the same AZs so a request can stay in one AZ from start to finish.
Common errors
- Removing resilience to save money. Putting everything in one AZ removes the cost and the fault tolerance. Keep capacity in at least two AZs and reduce traffic through routing.
- Turning off cross-zone with uneven targets. If AZ A holds 80% of the clients but 50% of the targets, the targets in A overload.
- Assuming hints are active. Check that Topology Aware Routing is working by looking at the EndpointSlice hints. A silent fallback means no savings.
- Ignoring public IPs. Traffic between instances that use public or Elastic IPs is billed as inter-AZ even when both are in the same AZ.
Exercise
An NLB with cross-zone load balancing turned on sends traffic to targets in three AZs. Name two changes that reduce inter-AZ charges, and one risk of each.
Show answer
Turn cross-zone off, so each NLB node sends traffic only to targets in its own AZ. The risk is overload if targets or clients are unevenly spread across AZs. Alternatively, run the clients and targets in matching AZs and use zone-aware routing, such as Topology Aware Routing. The risk is that hints are dropped if pods are unevenly distributed, which brings back the charges.