The egress costs nobody budgets
Data transfer out, between zones and between regions is the part of a cloud bill that depends on how your systems talk to each other. Where the charges come from and how to find them early.
I have watched teams estimate compute to the instance-hour and storage to the gigabyte, then put one line at the bottom of the spreadsheet called "network" with a round number in it. The round number is always too small. Data transfer is the part of a cloud bill that depends on how your systems talk to each other, and the estimate is usually written before anyone knows that.
I am leaving rates out of this on purpose. They differ by provider, region and volume tier, and they change. The mechanisms are stable, so learn those and then read the current price page.
Where the charges come from
Start with the rule that makes this confusing. Data coming in from the internet is free on the large providers. AWS's billing documentation says so directly, and Azure's bandwidth page lists inbound transfer as free. Data going out is metered per gigabyte. So the bill follows the direction of the bytes, and the same link can be free one way and charged the other.
Out to the internet. This is the charge people know about. AWS and Azure both give the first 100 GB a month free, and after that you pay per gigabyte in tiers. Anything that serves large responses to users, ships backups to another provider, or feeds an analytics tool outside the cloud lands here.
Between zones. This is the one that catches well-designed systems. You spread a service across availability zones because that is how you get resilience. On AWS, traffic inside one zone is free and traffic between zones in the same region is charged. The billing documentation notes that it is metered on both the sending and the receiving resource, so one transfer shows up as two line items. A chatty application tier in one zone talking to a database in another pays on every query and every result. So does replication between the nodes of anything clustered. Providers differ on this point, so check yours.
Between regions. Disaster recovery copies, cross-region replication and central logging all move data from one region to another. On AWS the source region is charged for sending and the destination is not charged for receiving. The rate depends on which two regions are involved.
Through a NAT gateway. Instances in private subnets reach the outside through a NAT gateway, and the gateway charges a per-gigabyte processing fee for everything that passes through it. AWS's pricing page is explicit that standard data transfer charges apply on top. This one hides well, because much of the traffic is operating system updates, container image pulls and calls to the provider's own storage service, all taking the long way round. AWS notes that a gateway endpoint for S3 carries no hourly or data processing charge, which deals with a large share of it.
To other parties. Sending logs and metrics to a monitoring vendor is internet egress. So is a nightly export to a data warehouse hosted elsewhere, and so is a partner pulling files from your storage bucket.
Data coming in from the internet is free on the large providers. Rates differ by provider, region and volume tier.
Finding them before the bill does
If the workload is already running, the bill itself will tell you. On AWS, data transfer appears in the cost and usage report under usage types with recognizable names, usually with a region prefix: DataTransfer-Out-Bytes for internet egress, DataTransfer-Regional-Bytes for traffic between zones, and names built from two region codes followed by AWS-Out-Bytes for traffic between regions. Group your costs by usage type and sort. Most people who do this for the first time find one line they cannot explain, and that line is where to start.
Then find out which resources are responsible. Tags get you part of the way, and network flow logs fill in the rest because they show which addresses exchange the most bytes. The list of top talkers usually explains most of the charge.
If the workload is not built yet, do it on paper. Draw the data flows, every arrow, including the boring ones: replication, backups, log shipping, image pulls, health checks. For each arrow write the volume per month and mark each boundary it crosses, whether that is a zone, a region, a NAT gateway or the internet. Arrows that cross a boundary and carry real volume go in the budget as their own lines. This takes an afternoon, and it is the only version of the estimate I trust.
A few fixes come up again and again.
- Put the chattiest pairs in the same zone when your availability design allows it. That is a trade against resilience, so make it deliberately and per component.
- Use gateway endpoints for the provider's own services, where they are offered, so that traffic stops flowing through the NAT gateway.
- Compress before you send. You pay for bytes.
- Move the processing to the data. If an analytics job pulls a large data set out of the cloud to crunch it elsewhere, run the job where the data is and ship the result.
- Look at where your logs go. Verbose logging to an outside service is egress that grows with traffic.
- Set a budget alert on the data transfer usage types specifically. An alert on total spend fires too late to tell you which flow moved.
One caveat. Sometimes the charge is the right price for what you are getting. Spreading across zones costs transfer fees and buys you survival of a zone failure, and I would pay that for most production systems. What I want is for the number to be known in advance and chosen on purpose.
Who owns this line
In most organizations, nobody does. The network team does not control how the application behaves, and the application team does not see the bill at this level of detail. So the line grows until it is large enough to be an incident.
Give it an owner. My preference is the team that owns the application, since they control how much it talks and to whom, with the platform team responsible for giving them the breakdown every month.
You can start today with last month's bill grouped by usage type. It takes a few minutes to produce, and it will show you whether you have a data transfer problem before you spend any time on the fixes above.
Sources
- https://docs.aws.amazon.com/cur/latest/userguide/cur-data-transfers-charges.html
- https://aws.amazon.com/blogs/architecture/overview-of-data-transfer-costs-for-common-architectures/
- https://aws.amazon.com/vpc/pricing/
- https://aws.amazon.com/ec2/pricing/on-demand/
- https://azure.microsoft.com/en-us/pricing/details/bandwidth/
Views are my own.