Lesson 2 of 3 Storage, Data Transfer and Database Optimization

Data Transfer Optimization

Data transfer is one of the most commonly overlooked drivers of cloud cost, because it depends on how data flows rather than on the size of resources. This lesson explains how transfer is charged and the architectural techniques that reduce it.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain how data transfer is charged by direction and path.
  • Explain why transfer cost surprises teams and how to find it.
  • Describe techniques that reduce internet egress.
  • Describe techniques that reduce internal transfer while keeping resilience.

How data transfer is charged

Providers charge for data according to its direction and path. The following list describes the typical pattern; exact rules and prices vary by provider and region.

  • Inbound data from the internet into the cloud is usually free.
  • Outbound data to the internet (egress) is charged per gigabyte, usually in tiers that become cheaper with volume.
  • Inter-region data between regions of the same provider is charged per gigabyte.
  • Inter-zone data between availability zones in the same region is charged on many providers, often in each direction.
  • Intra-zone data within one zone over private addresses is usually free.
  • Gateways, such as NAT gateways, add a per-gigabyte processing charge on top of any transfer charge.
Sort into groups

Charged or free?

Exam skills 7.2.2

Decide whether each transfer is typically charged.

Log in to try this activity Interactive activities are free with an account.

Why transfer cost surprises teams

Transfer cost does not appear in a list of resources. It emerges from traffic patterns: a microservice that calls another service in a different zone thousands of times a second, a replication job copying a database to another region, containers pulling images through a NAT gateway, or logs shipped across regions to a central account. Each looks harmless in a design diagram, and together they can become a large share of the bill. Billing data grouped by usage type reveals transfer charges, and flow logs can show which resources generate them.

Reducing internet egress

A content delivery network (CDN) caches content at edge locations close to users, which reduces load on the origin and often lowers the price per gigabyte delivered, because CDN egress is typically priced lower than direct egress and origin-to-CDN transfer is often discounted or free within the same provider. Compression of responses and assets, efficient image and video formats, and avoiding unnecessary payload fields all reduce the volume sent.

Reducing internal transfer

Inside the cloud, the following techniques reduce transfer cost while respecting resilience requirements.

  • Zone-aware routing: prefer calling a service instance in the same zone, falling back to other zones only when needed.
  • Private endpoints: reach provider services such as object storage through private endpoints or gateway endpoints instead of through NAT gateways.
  • Local caching: cache container images and dependencies, and use registries in the same region.
  • Process data where it lives: run analytics in the region where the data is stored instead of copying it.
  • Review replication: replicate across regions only data that the recovery objectives require.

The following diagram compares the path through a NAT gateway with an endpoint.

Removing NAT processing charges for traffic that never leaves the provider's network. Traffic from private subnets to same-region object storage through a NAT gateway pays a per-gigabyte processing charge. A private or gateway endpoint routes the traffic directly; on AWS, gateway endpoints for Amazon S3 have no hourly or data processing charge.
Endpoint pricing differs by provider and endpoint type.
Scenario questions

Reducing transfer cost

Exam skills 7.2.2

Choose the most effective change to reduce data transfer cost.

Log in to try this activity Interactive activities are free with an account.

Finding transfer cost in the data

Transfer charges are spread across many services in billing data, so they are easy to miss in a view grouped by service. Grouping by usage type or charge description, or filtering for data transfer in the service category, brings them together and shows whether they come from internet egress, inter-region traffic, inter-zone traffic or gateway processing. In FOCUS data, the ChargeDescription and the consumed unit (gigabytes) help identify these rows.

Billing data shows how much transfer cost and on which resource it was charged, but not which service called which. Flow logs from the virtual network, and service-level metrics such as bytes sent per endpoint, show the source and destination of traffic. Combining the two lets engineers attribute a transfer charge to the design decision that causes it.

Resilience still matters

Keeping everything in one zone would eliminate inter-zone charges, but it would also remove protection against zone failures. The goal is not to avoid cross-zone traffic altogether but to avoid unnecessary cross-zone traffic, such as chatty calls that could be served locally, while keeping redundancy across zones.

Worked example

The NAT gateway bill

A cluster in private subnets pulls 300 TB a month from object storage in the same region through a NAT gateway that charges USD 0.045 per GB processed. How can the cost be reduced?

The NAT processing charge is about 300,000 x 0.045 = USD 13,500 a month, for traffic that never leaves the provider's network. Adding a private or gateway endpoint for the object storage service routes this traffic directly, removing the NAT processing charge. On AWS, for example, gateway endpoints for Amazon S3 have no hourly or data processing charge. The change also reduces load on the NAT gateway.

Worked example

Cross-zone chatter

A service in three zones calls a cache cluster, and requests are spread evenly across all cache nodes. Monthly cross-zone traffic is 200 TB at USD 0.01 per GB in each direction. What could be done?

With even spreading, about two thirds of calls cross a zone boundary. Charged in each direction, 200 TB costs about 200,000 x 0.02 = USD 4,000 a month. Zone-aware routing to a cache replica in the same zone, where the cache supports it, could remove most of this traffic while keeping replicas in every zone for resilience.

Check yourself

How do private or gateway endpoints reduce cost for traffic from private subnets to provider services?

Show answer

They route the traffic directly to the service instead of through a NAT gateway, which removes the NAT per-gigabyte processing charge.

Exam Tips

Remember for the exam

  • Inbound is usually free; egress, inter-region and often inter-zone transfer are charged.
  • NAT gateways add per-gigabyte processing charges; private endpoints avoid them for provider services.
  • CDNs and compression reduce internet egress.
  • Reduce unnecessary cross-zone traffic without removing multi-zone resilience.