Cloud Networking and VPC Design Questions
Designing networks inside a cloud provider: VPC/VNet topology, subnets, route tables, gateways, NAT, and peering, plus private connectivity through VPC endpoints and cloud load balancers. Covers segmentation, security groups and network ACLs, hybrid connectivity to on-premises data centers over VPN or dedicated links like Direct Connect and ExpressRoute, IP address planning across many VPCs and accounts, and how cloud network design differs from traditional data-center networking.
Describe the public/private subnet pattern for a multi-tier application (web, application, database) in a VPC. For each tier specify whether it belongs in a public or private subnet, where NAT/IGW is required, typical routing and ACL/security-group configuration, and how this pattern improves security and manageability.
Sample Answer
Direct answer
The public/private subnet split for a multi-tier app puts only the resources that must accept unsolicited inbound internet traffic (the web tier) in a public subnet, and everything else (application, database) in private subnets that are unreachable from the internet by construction. Security is improved because the blast radius (how far an attacker who breaches one tier can then reach) of an internet-facing compromise stops at the first tier: even with a perfect security-group rule set, only the route table decides whether an internet path exists at all, and the private tiers simply have none. Manageability improves because each tier gets its own routing and firewall boundary, so a change to one tier's exposure cannot silently affect another.
Structured elaboration
Per-tier breakdown:
| Tier | Subnet type | Internet Gateway (IGW) route needed? | NAT needed? | Typical inbound security-group rule | Typical NACL posture |
|---|---|---|---|---|---|
| Web (or a load balancer in front of it) | Public | Yes, 0.0.0.0/0 -> IGW | No (it already has a public path) | Allow 443/80 from 0.0.0.0/0 | Default allow, tightened only if the NACL is doing broad IP blocking |
| Application | Private | No | Yes, for outbound calls to third-party APIs or OS updates | Allow the app port from the web tier's security group only | Allow ephemeral return traffic (1024-65535) plus the specific inbound app port from the web subnet's CIDR |
| Database | Private | No | Usually no route at all; databases rarely need outbound internet | Allow the database port (e.g. 5432 for PostgreSQL) from the app tier's security group only | Allow ephemeral return traffic plus the database port from the app subnet's CIDR only |
Route tables, concretely. Each subnet associates with exactly one route table (though one route table can serve several subnets). The public subnet's table has a route for the VPC's own CIDR (added automatically, cannot be deleted) plus 0.0.0.0/0 -> igw-xxxx. Each private subnet's table has the local VPC route plus 0.0.0.0/0 -> nat-xxxx if it needs outbound internet, pointed at the NAT gateway that lives in a public subnet (a NAT gateway needs a public subnet and its own Elastic IP to reach the internet on behalf of everyone routing through it).
Security group vs NACL in this pattern, briefly (the full comparison is its own topic, but the shape that matters here): security groups are stateful and attached to the instance or its network interface, so you write one inbound rule and return traffic is automatically allowed back out. NACLs are stateless and attached to the subnet, evaluated before the security group, so you must explicitly allow both the inbound request and the ephemeral-port outbound return traffic, or connections will hang. Most teams run security groups as the primary control and leave NACLs at their permissive default unless they have a specific reason (blocking a known-bad IP range at the subnet boundary, or enforcing a hard compliance boundary that must hold even if every security group is misconfigured).
Worked example
A two-Availability-Zone (AZ) checklist for a 3-tier app, since anything less than two AZs is not actually highly available:
- One public subnet per AZ (e.g.
10.0.0.0/24in AZ-a,10.0.1.0/24in AZ-b) holding the load balancer and, if used, a bastion or jump host. - One private application subnet per AZ (
10.0.10.0/24,10.0.11.0/24). - One private database subnet per AZ (
10.0.20.0/24,10.0.21.0/24), often placed in a dedicated "DB subnet group" so the managed database service only ever launches replicas into subnets you intended for it. - One NAT gateway per AZ (not one shared NAT gateway for the whole VPC): if the only NAT gateway lives in AZ-a and AZ-a fails, AZ-b's private resources lose outbound internet access even though their own AZ is healthy. Each AZ's private route tables point only at their own AZ's NAT gateway.
- Security groups chained tier to tier as in the table above: load-balancer security group accepts the internet, web/app security group accepts only the load-balancer's security group, database security group accepts only the app security group.
Secure administrator access, without a public jump box. A classic weak point in this pattern is putting a bastion host in the public subnet with SSH open to a corporate IP range, which is one more standing internet-facing attack surface to patch and monitor. The current recommended pattern (AWS Systems Manager Session Manager, or Azure Bastion / GCP Identity-Aware Proxy on the other clouds) removes that: the administrator authenticates through the cloud provider's identity and access management (IAM), and the agent already running on the instance opens an outbound-only connection to the Session Manager service, so no inbound port needs to be open on the instance at all, not even from a "trusted" IP range. That also gets you centralized, immutable session logging for free, which a bare SSH bastion does not.
Trade-offs and pitfalls
The single most common mistake in this pattern is a shared, single-AZ NAT gateway "to save cost," which quietly turns a multi-AZ design into one with a single point of failure for all outbound internet access; it also concentrates all cross-AZ private-subnet egress traffic onto one gateway and one AZ's data-transfer path. A second pitfall is treating "private subnet" as sufficient security on its own and skipping the security-group chaining: a private subnet stops internet ingress, but without tier-to-tier security group rules, anything else already inside the VPC (a compromised instance in the same VPC, or an overly broad peering connection) could still reach the database directly. Finally, teams sometimes forget that NACLs are stateless when they add a "temporary" outbound-only NACL rule and wonder why responses never arrive: without the matching ephemeral-port inbound rule, the return leg of the connection is dropped at the subnet boundary even though the security group would have allowed it.
At a high level, explain AWS VPC Peering versus AWS Transit Gateway. For which scenarios would you recommend Transit Gateway over peering as the number of VPCs grows, and why? Discuss scaling, route propagation, centralization of services, and cost implications.
Sample Answer
Direct answer
VPC Peering is a direct, point-to-point private connection between exactly two Virtual Private Clouds (VPCs) that routes as if they were on the same network, with no gateway or extra hop in between. Transit Gateway is a managed hub: every VPC, VPN, and Direct Connect connection (a dedicated private network link from an on-premises facility into the cloud, unlike peering or a Transit Gateway attachment) attaches to it once, and the Transit Gateway routes between all attached networks according to its own route tables, so no VPC needs a direct connection to any other. Peering makes sense while the number of VPCs that need to talk to each other is small; Transit Gateway earns its keep the moment that number grows enough that a full mesh of peering connections becomes the harder thing to operate, not the cheaper one.
Structured elaboration
Why peering does not scale on its own: the mesh problem. Peering is non-transitive: if VPC A peers with VPC B, and B peers with C, A cannot reach C through B: A needs its own direct peering connection to C. Connecting N VPCs so that all of them can reach each other requires N x (N-1) / 2 peering connections. That is 10 connections for 5 VPCs, 45 for 10 VPCs, and 190 for 20 VPCs: it grows quadratically, not linearly, and each one is a separate resource to create, route, and eventually decommission.
| Dimension | VPC Peering | Transit Gateway |
|---|---|---|
| Topology | Point-to-point, non-transitive | Hub-and-spoke; every attachment can reach every other attachment (subject to route tables) |
| Scaling | Quadratic connection count as VPCs grow | Linear: one attachment per VPC, regardless of how many VPCs there are (up to the attachment quota) |
| Route propagation | Manual: add a route in each peered VPC's route table pointing at the peering connection | Centralized: Transit Gateway route tables control reachability for every attached network in one place |
| Centralizing shared services | Awkward: a "hub" VPC still needs a direct peering connection to every spoke | Natural: attach a shared-services VPC once and every other attachment can reach it through Transit Gateway routing, no extra connections needed |
| Cross-account | Supported, but each connection needs manual accept/request handling per account pair | AWS Resource Access Manager (RAM) lets you share one Transit Gateway across accounts, so onboarding a new account's VPC is one attachment, not N new peering connections to every existing account |
| Cost | No hourly charge for the peering connection itself, only standard data-transfer rates | Hourly charge per attachment plus a per-gigabyte data-processing charge on top of data-transfer rates |
| Known limitations | CIDR blocks (the IP address ranges assigned to each VPC, written like 10.0.0.0/16) of the two VPCs must not overlap; peering does not by itself enable private DNS resolution across the connection, you must explicitly enable DNS resolution support on both sides for private hostnames to resolve to private IPs across the peering connection | Higher baseline cost per attachment; adds an extra network hop and its own route tables to reason about |
When to recommend Transit Gateway over peering as VPC count grows. The decision point is not a fixed VPC count so much as whether you are trending toward needing most VPCs to reach most other VPCs (or a shared set of services). A handful of VPCs with a narrow, stable set of point-to-point relationships (say, a data VPC that only ever needs to talk to two specific application VPCs) can stay on peering indefinitely; the operational cost of two or three peering connections is trivial. The moment you are adding a new VPC every few weeks and each one needs to reach a shared-services VPC (logging, a central database, a security tooling VPC), Transit Gateway turns "one new peering connection per existing VPC that needs access" into "one new attachment, done." A concrete trigger worth naming: an organization running around 25 VPCs across several AWS accounts that all need to reach a shared services VPC is already past the point where peering is the simpler design, since that shared VPC alone would need roughly 25 separate peering connections, each with its own route-table entries to maintain, versus 25 straightforward Transit Gateway attachments managed from one set of route tables.
Worked example
A company starts with 3 VPCs: production, staging, and a shared-services VPC holding a central logging pipeline. Three peering connections (prod-shared, staging-shared, and, if prod and staging ever need to talk directly, prod-staging) is entirely reasonable; nobody should reach for Transit Gateway here. Eighteen months later the company has grown to 12 AWS accounts, each with its own VPC, all needing to reach that same shared-services VPC and, in a few cases, each other. A full mesh at that scale would need up to 66 peering connections; even the minimal "everyone talks only to shared-services" star topology needs 12 direct peering connections, each independently routed, and every new account added means one more. At this point the team migrates to Transit Gateway: shared with the other 11 accounts through AWS Resource Access Manager (RAM) so each account owner attaches their own VPC without the central network team creating a connection per account, and Transit Gateway route tables enforce that spoke VPCs can reach shared-services but not each other directly, a segmentation policy that would have required careful, individually maintained route tables in a pure-peering design.
Trade-offs and pitfalls
The most common mistake is reaching for Transit Gateway on day one "for future-proofing" when 2 or 3 VPCs are the entire foreseeable footprint: it adds an hourly per-attachment cost and an extra hop for no benefit if the mesh never grows past a size peering handles comfortably. The opposite mistake, staying on peering well past the point of diminishing returns, is more common and more expensive to unwind: teams often notice the problem only when they are maintaining dozens of peering connections' worth of route-table entries by hand and a single new VPC onboarding takes a checklist of individual peering requests. A specific peering gotcha worth calling out explicitly: even after a peering connection is active and routes exist, resources will fail to resolve each other's private DNS names across it until DNS resolution support is explicitly enabled on both VPCs' sides of the connection, which is easy to miss because the underlying IP connectivity works fine and masks the DNS gap until someone's code tries to connect by hostname instead of IP.
Compare connectivity options for connecting on-premises data center to cloud: VPN over internet, dedicated private link (AWS Direct Connect / Azure ExpressRoute), and third-party SD-WAN. For each option describe bandwidth, latency, security, cost, and typical use-cases.
Sample Answer
Direct answer
For connecting an on-premises data center to the cloud, VPN over the internet is the cheapest and fastest to stand up but inherits the public internet's variable latency and has no cloud-provider service-level agreement (SLA) for the path outside the cloud; a dedicated private link (AWS Direct Connect or Azure ExpressRoute) gives consistent, high-bandwidth, low-latency connectivity backed by an SLA but costs more and takes longer to provision; third-party SD-WAN (software-defined wide area network) sits above either underlying transport and adds centralized policy, application-aware routing, and often automatic failover across multiple links, at the cost of another vendor and management layer. The right choice depends on what the workload actually needs: sporadic, low-volume, latency-tolerant traffic fits VPN; sustained, latency-sensitive, or compliance-bound traffic justifies a dedicated connection; and a multi-site organization managing many locations' connectivity centrally often layers SD-WAN over one or both.
Structured elaboration
| Dimension | VPN over internet | Direct Connect / ExpressRoute | Third-party SD-WAN |
|---|---|---|---|
| Bandwidth | Per-tunnel throughput is capped (roughly 1.25 Gbps per standard tunnel on AWS, up to 5 Gbps on a large-bandwidth tunnel); multiple tunnels can be aggregated with equal-cost multi-path (ECMP) routing for more | Dedicated ports from 1 Gbps up to 100 Gbps (with higher speeds available at a growing number of locations), or smaller hosted connections from a partner starting well under 1 Gbps | Depends entirely on the underlying transport it rides over (broadband, LTE/5G, or a dedicated circuit); SD-WAN itself adds no bandwidth |
| Latency | Variable, subject to internet routing and congestion ("internet weather") | Consistent and generally lower, since traffic stays on the provider's dedicated or partner backbone rather than the public internet | Depends on the underlying links; SD-WAN can steer latency-sensitive traffic onto the better-performing link in real time if more than one is available |
| Security | Encrypted (IPsec, a protocol suite that encrypts traffic between the two endpoints) by design, traveling over the public internet | Not encrypted by default (a private circuit, not automatically an encrypted tunnel); pair with MACsec (an encryption standard applied at the physical link itself) or an overlay VPN if encryption-in-transit is a requirement | Depends on configuration; most SD-WAN products layer their own encrypted overlay regardless of the underlying transport |
| Cost | Lowest: no dedicated circuit, pay for the VPN gateway and data transfer | Higher: a physical cross-connect, port-hour charges, and often a colocation or partner fee on top | Additional licensing and appliance cost on top of whatever transport it rides over |
| Provisioning time | Fast, often same-day, since it is purely a software/configuration change on both ends | Slow, commonly weeks, since it involves a physical cross-connect at a colocation facility or a partner's hosted connection process | Fast for the SD-WAN layer itself, bounded by however long the underlying transport takes to provision |
| Reliability commitment | No AWS/Azure SLA for the internet portion of the path, since neither provider controls the public internet in between | Backed by an SLA when deployed in a resilient configuration (multiple connections across multiple locations); a single connection has no SLA and is not recommended for production | Depends on the SD-WAN vendor's own SLA and on the underlying transport's SLA |
| Typical use case | Backup path, low-to-moderate traffic, development/test connectivity, or a bridge while a dedicated circuit is being provisioned | Production workloads needing predictable performance, large sustained data volumes, or a compliance requirement to avoid the public internet | Organizations with many branch sites needing centrally managed, policy-driven routing across a mix of link types |
Worked example
Migration framing. A retailer doing a lift-and-shift of its on-premises data center to the cloud initially connects over a Site-to-Site VPN to start moving non-critical workloads immediately, since the VPN can be live the same day and the migration timeline cannot wait weeks for a physical cross-connect. In parallel, they order a Direct Connect circuit at a colocation facility, which takes on the order of weeks to provision. Once Direct Connect is live, they configure Border Gateway Protocol (BGP) so the dedicated circuit is preferred for all cloud-bound traffic (achieved by advertising a shorter AS-path or a better local-preference value on the Direct Connect side) with the VPN kept active as an automatic failover path, giving the migration both a fast start and, once ready, a durable dual-path design rather than a one-time VPN that later has to be torn out and replaced. For cross-region resilience during the migration window, they also plan bandwidth headroom on both paths so a regional failover does not saturate whichever link absorbs the shifted traffic.
Cost-driven recommendation for a scheduled bulk-transfer workload. A different team runs a nightly batch job transferring a large, predictable volume of data (say, tens of terabytes) from an on-premises system to cloud storage during a fixed overnight window. Because the volume is large and the timing is predictable and recurring (not sporadic), the data-transfer economics favor Direct Connect as the primary path, sized to comfortably clear the nightly volume inside the batch window, with an IPsec VPN kept purely as a failover for the rare case the dedicated circuit is down during that window. Sizing the VPN failover path only needs to cover the batch's minimum acceptable throughput, not match Direct Connect's full capacity, since it exists to avoid a missed run, not to be the steady-state path.
Reliability comparison, concretely. An internet-path VPN carries no AWS or Azure commitment for the portion of the trip between the customer's router and the cloud provider's edge; if a transit provider somewhere on the public internet degrades, there is no SLA to invoke against the cloud provider for that. A Direct Connect connection, deployed as multiple connections terminating on separate devices across more than one physical location (the resiliency model AWS recommends for production), carries an SLA and a defined mean-time-to-repair (MTTR) commitment for the dedicated portion of the path; a single, non-redundant Direct Connect connection, by contrast, carries no SLA at all, which is a common and costly misunderstanding.
Trade-offs and pitfalls
The most common mistake is ordering a single Direct Connect connection and treating it as production-ready simply because it is "dedicated": without a second connection on a separate device, ideally at a second location, there is no SLA and no protection against a single device or facility failure, which defeats much of the point of choosing Direct Connect over VPN in the first place. A second pitfall is under-provisioning the VPN failover path's bandwidth on the theory that it will "rarely" be used, then discovering during an actual Direct Connect outage that the VPN cannot carry production traffic at an acceptable level either. Finally, teams evaluating SD-WAN sometimes expect it to fix underlying transport problems it cannot fix. SD-WAN can steer traffic intelligently across the links you give it and add centralized policy, but it does not manufacture bandwidth or eliminate the latency characteristics of a genuinely poor underlying link.
Explain what a Virtual Private Cloud (VPC) is across AWS, Azure, and GCP. Describe the core components (subnets, route tables, internet gateway or equivalent, NAT, security groups, and network ACLs) and explain the differences between public and private subnets. Provide a simple example layout for a 3-tier web application (web, app, db), indicating which tiers belong in public vs private subnets and why.
Sample Answer
Direct answer
A Virtual Private Cloud (VPC), called a VNet (Virtual Network) on Azure, is a logically isolated, software-defined slice of a cloud provider's physical network that you carve out for your own resources. You define its private IP address range, split it into subnets, control what can route in and out, and layer firewall rules on top. The building blocks are the same on AWS, Azure, and GCP even though the names differ: an address space, subnets that place resources in specific zones, route tables that decide where traffic goes, an internet-facing gateway, NAT (Network Address Translation: swapping a private IP address for a public one) for outbound-only internet access, and two layers of firewalling (one per instance, one per subnet).
Structured elaboration
Core components, mapped across the three providers:
| Concept | AWS | Azure | GCP |
|---|---|---|---|
| The network container | VPC | VNet (Virtual Network) | VPC network (global, not regional) |
| Subdivision by zone | Subnet (tied to one Availability Zone, AZ) | Subnet (tied to a region, zone-redundant) | Subnet (regional, spans all zones in that region) |
| Routing rules | Route table | Effective routes / User-Defined Routes (UDR) | Routes (global, automatic + custom) |
| Path to the public internet | Internet Gateway (IGW) | Public IP + (optionally) an internet-facing NAT gateway or load balancer | Default route via the implied internet gateway |
| Outbound-only internet for private resources | NAT Gateway | Azure NAT Gateway | Cloud NAT |
| Instance-level firewall | Security group (stateful, attached to the elastic network interface, ENI) | Network Security Group (NSG), same idea | Firewall rules (tag or service-account scoped, VPC-wide but effectively per-instance) |
| Subnet-level firewall | Network ACL (NACL, stateless) | NSG can also attach to a subnet | No separate stateless layer; firewall rules are the only layer |
The one structural difference worth knowing cold: AWS and Azure subnets are pinned to a single AZ, so a highly available design needs one subnet per tier per AZ. GCP subnets are regional and automatically span every zone in that region, so a GCP design needs far fewer subnet objects to get the same zonal spread.
Public vs private subnet, the actual definition. A subnet is "public" only because its route table sends 0.0.0.0/0 (all internet-bound traffic) to an internet gateway. A subnet is "private" when its route table has no such route: outbound internet access, if any, goes through a NAT gateway instead, and there is no path for unsolicited inbound traffic from the internet at all. Nothing about the subnet's IP range or a checkbox makes it public or private; it is entirely a routing decision. That means you can silently turn a private subnet public by adding one route, which is why route tables are the thing to audit, not subnet names.
- Public subnet: route table has a
0.0.0.0/0 -> IGWroute. Resources here can receive inbound connections from the internet if a security group allows it (a public web server, a load balancer, a bastion host). - Private subnet: no route to an IGW. Resources here cannot be reached directly from the internet. If they need outbound internet access (to pull OS patches or call a third-party API), traffic is routed through a NAT gateway that lives in a public subnet, which translates their private addresses to its own public one and hides them from unsolicited inbound connections.
Worked example
A standard 3-tier web application, one AZ shown (repeat per AZ for high availability):
graph TD
INTERNET((Internet)) --> IGW[Internet Gateway]
IGW --> ALB[Load Balancer - public subnet]
ALB --> WEB[Web tier - public subnet]
WEB --> APP[App tier - private subnet]
APP --> DB[(Database tier - private subnet)]
APP --> NAT[NAT Gateway - public subnet]
NAT --> IGW
- Web tier: public subnet. It must accept inbound HTTP/HTTPS from arbitrary internet clients, so it needs the IGW route. Security group allows inbound 443 from 0.0.0.0/0 and nothing else.
- App tier: private subnet. It only ever receives traffic that the web tier forwards to it; nothing on the internet should be able to open a connection to it directly. Its security group allows inbound only from the web tier's security group, on the application port. It still needs outbound internet access for things like calling a payment API or pulling a dependency, which is why the private subnet's route table sends 0.0.0.0/0 to the NAT gateway, not the IGW.
- Database tier: private subnet, and stricter than the app tier. It has no legitimate reason to reach the internet at all (patches usually come through a maintenance window or a private mechanism, not a live outbound call), so many teams give it no NAT route whatsoever, only local VPC routes. Its security group allows inbound only from the app tier's security group, on the database port.
The reasoning behind this layout is defense in depth and blast-radius containment: if an attacker compromises the internet-facing web tier, the private subnets' lack of a route back from the internet, plus security groups that only trust the tier directly upstream, mean the attacker cannot reach the database in one hop. A common refinement worth naming even though it wasn't in the layout above: instead of routing the app tier's outbound calls to specific AWS services (object storage, a private API) through the NAT gateway and out to the internet and back, add a VPC endpoint. For example, a data-processing app pulling training data from S3 gets a Gateway Endpoint for S3, a routing-table entry that sends S3 traffic over AWS's internal network instead of through the NAT gateway and the public internet. That traffic no longer counts against NAT data-processing charges and never leaves AWS's backbone, which is both cheaper and a smaller attack surface. The same core-components list above (VPC, subnets, route tables, an internet gateway, NAT, security groups, NACLs) applies unchanged whether the workload sitting behind it is a web app, a data-processing cluster reading from object storage, or any other three-tier shape: the tier names change, the routing and isolation logic does not.
When you plan this layout, decide four things up front rather than reactively: how many Availability Zones you need (at least two, for anything that has to survive a zone outage), how big a CIDR block to give the VPC and each subnet (oversize subnets rather than sizing them to exactly today's instance count, since resizing a live subnet is disruptive), which tiers actually need internet reachability at all (fewer than people assume), and where you will need private connectivity to managed services later so you are not retrofitting a NAT bottleneck.
Trade-offs and pitfalls
The most common mistake is putting the application tier in a public subnet "to make debugging easier" and locking it down with security groups alone. Security groups are the right control for who can talk to an instance, but they do not stop a misconfigured resource, like a database with a public IP by accident, from being reachable from the internet in the first place; only the route table (no IGW route) guarantees that. A second pitfall is forgetting that a private subnet with no NAT route also has no outbound internet: this is fine for a database but will silently break an application tier that needs to call an external API, so "private" and "internet-reachable outbound" are two separate decisions you make per tier, not one. Finally, teams sometimes conflate "private subnet" with "encrypted" or "compliant"; subnet placement controls network reachability only; encryption, IAM (identity and access management: who is allowed to do what), and logging are separate controls layered on top.
You observed unexpectedly high network egress costs from a VPC driven by cross-AZ data transfer and NAT gateway usage. Describe a step-by-step approach to identify the cost drivers and recommend configuration or architectural changes to reduce network charges while maintaining security and availability. Include both short-term and long-term actions.
Sample Answer
Direct Answer
Cross-AZ (Availability Zone) data transfer and NAT gateway data processing are two separate charges with two separate fixes; measure each one before touching anything, then apply cheap short-term changes immediately (route AWS-native traffic off NAT entirely) and pursue architectural long-term changes (per-AZ NAT placement, egress proxies, Direct Connect) for whatever traffic genuinely still needs to leave.
Step-by-Step Diagnosis
- Pull Cost Explorer or the Cost and Usage Report filtered by usage type, the regional data-transfer line for cross-AZ bytes and the NAT gateway line for processed bytes, to size each driver in dollars rather than guessing which one dominates.
- Query VPC Flow Logs, already a good general practice to have enabled, grouped by source and destination subnet or Availability Zone, and separately by whether the destination ENI is a NAT gateway, to find which services or subnets actually generate the volume.
- Cross-reference against the deployment topology: is a chatty service pinned unevenly across zones, does a distributed data store's replication protocol inherently generate cross-zone traffic, is a batch job pulling large images or datasets through a single shared NAT gateway.
Reducing Cross-AZ Transfer
Prefer AZ-aware routing so a service calls a same-zone backend when one is healthy, cutting east-west cross-zone hops. But distinguish cross-zone traffic that is buying you something, quorum writes and multi-zone replication that provide the durability guarantee, from cross-zone traffic that is just an accident of default load-balancer or scheduler behavior. Only the second kind is waste worth removing.
Reducing NAT Gateway Costs
The most commonly overlooked driver is traffic to AWS-native services, object storage, a managed database, a container registry, that never needed to leave the AWS network in the first place.
Short term. Add Gateway VPC endpoints for object storage and the managed database service (no hourly or per-gigabyte charge) immediately; this alone commonly removes a large share of NAT-billed traffic as a same-day, low-risk change. Add Interface VPC endpoints (AWS PrivateLink) for other heavily used AWS APIs; these carry their own hourly and per-gigabyte cost but are still typically far cheaper than routing the same traffic through NAT, and they remove a public-internet hop for API calls.
Long term. Deploy one NAT gateway per Availability Zone, with each zone's private subnets routing to their own zone's NAT gateway rather than all zones sharing a single NAT gateway in one zone. A shared NAT gateway is itself a generator of the OTHER cost driver in this question, because reaching it from another zone is a cross-AZ transfer. Fixing NAT placement per zone addresses both drivers at once. For very high, predictable outbound volume, an egress proxy fleet you operate yourself can undercut NAT Gateway's linear per-gigabyte charge at scale, worth it only above a volume threshold you should size against your own numbers first. For predictable, large, recurring egress to one external partner, AWS Direct Connect's per-gigabyte egress via a dedicated circuit is typically cheaper than internet egress through NAT at sustained high volume.
None of this trades away security or availability: VPC endpoints remove a public-internet path rather than weakening anything, and per-AZ NAT preserves the standard high-availability pattern AWS itself recommends, avoiding a single NAT gateway becoming a single point of failure for an entire region's egress.
Worked Example
Assume a service moves 10,000 GB per month through a single, shared NAT gateway in one zone, while half its callers run in a different zone, so 5,000 GB of that traffic first crosses zones before it is even NAT-processed. Using AWS's published per-region rates as of this writing (verify current rates for your own region before relying on this), NAT Gateway data processing at $0.045 per GB and cross-AZ data transfer at $0.01 per GB in each direction:
NAT processing=10,000 GB×$0.045/GB=$450/month Cross-AZ transfer (5,000 GB, one direction into the NAT’s zone)=5,000 GB×$0.01/GB=$50/month Combined avoidable driver=$450+$50=$500/month before any endpoint offloadIf the flow-log analysis shows 40% of that 10,000 GB is object-storage or managed-database traffic that a Gateway Endpoint removes from NAT entirely:
NAT volume after endpoint offload=10,000×(1−0.40)=6,000 GB New NAT processing cost=6,000×$0.045=$270/monthAdding per-AZ NAT removes the remaining 5,000 GB cross-AZ leg entirely, since each zone's traffic now reaches its own local NAT gateway:
Total after both fixes=$270+$0=$270/monthThat is a 46% reduction, from $500 to $270 per month, using only endpoint offload and per-AZ NAT placement, before considering the higher-effort egress-proxy or Direct Connect options. These are illustrative inputs to show the arithmetic, not a claim about any specific account's real traffic; rerun this against the account's actual Cost Explorer and flow-log numbers.
Trade-offs and Pitfalls
Deploying a NAT gateway per zone raises the fixed hourly charge, since each NAT gateway bills independently; for a genuinely low-traffic, occasional-egress workload, consolidating to fewer NAT gateways can sometimes cost less in absolute dollars than three times the hourly charge. Run the numbers for the real traffic profile rather than applying "one NAT per zone" as a rule with no math behind it.
Treating all cross-AZ traffic as waste is a mistake; a large share of it is the price of durability and availability guarantees, and removing it means giving up those guarantees, not optimizing.
An egress proxy fleet shifts cost from a fully managed AWS service to something the team operates and patches; only justified once the operating cost is clearly smaller than the NAT savings at the account's actual volume.
Never present a specific dollar savings figure to stakeholders without redoing this math against the account's real Cost Explorer numbers first; the worked example above is a template for the calculation, not a promise.
Unlock Full Question Bank
Get access to all 11 Cloud Networking and VPC Design interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.