The cost of a message broker spread across availability zones
Why brokers across zones multiply traffic between zones, how to measure it on AWS and when one zone per region is enough.
- BITServices team
- #aws
- #architecture
High availability inside a region usually means spreading everything across availability zones. That is a good default. But if your system already runs in several regions with failover between them, zone-level redundancy may be protecting you from a risk you have already covered, and the traffic it creates can cost a lot.
What AWS charges
Traffic between availability zones in the same AWS region costs $0.01 per GB in each direction, so $0.02 per GB for every gigabyte that crosses a zone. On a busy system that adds up quietly, because it does not show up as a separate service. It hides in the EC2 data transfer lines of the bill.
Why message brokers make it worse
A broker cluster spread across three zones multiplies traffic in two ways.
Routing. A message published to a node in zone A is often consumed by a service in zone B or C. Every hop between a producer, the broker node and a consumer can cross a zone.
Replication. Replicated topics and streams copy every message to nodes in the other zones. With three replicas, one message written once crosses zones at least twice before anyone reads it.
This is the same for Kafka, RabbitMQ quorum queues and NATS JetStream. Services that call each other directly over HTTP or gRPC across zones have the same problem, only spread over many smaller calls.
Find out how much it costs you
- In the AWS cost and usage report, filter for usage types ending in
DataTransfer-Regional-Bytes. That is the traffic between zones. - Turn on VPC flow logs and group the traffic by source and destination instance or subnet. This shows which services are responsible.
- For each of them, write down what the zone redundancy protects against and what it costs per month.
Options, from small to large
- Keep reads in the same zone. Kafka can let consumers read from the nearest replica (follower fetching). Kubernetes can route service traffic to endpoints in the same zone first (topology aware routing).
- Turn off cross-zone load balancing on load balancers where it is not needed.
- Run the broker and its clients in one zone per region, if failover between regions already covers the loss of a zone. Test that failover before and after.
The last option is the most effective and the one that needs the most care. It is a decision about risk, not only about cost, and it should be made with the people who own availability.
What it saves
In one of our projects the message broker in every region ran across several zones, while failover between regions already covered the loss of a zone. Keeping that traffic inside one zone per region saved $140k a year on AWS, and availability did not change.