No history yet

VPC High-Throughput Networking

High-Bandwidth Inter-VPC Communication

When building distributed machine learning systems, gradient synchronization and data sharding between nodes demand extremely low-latency, high-bandwidth connections. The choice between VPC Peering and AWS Transit Gateway (TGW) is critical and hinges on a trade-off between raw performance and network manageability.

VPC Peering creates a direct, 1-to-1 connection between two VPCs. This is not a transitive relationship; if VPC A is peered with B, and B is peered with C, A cannot communicate with C through B. The key advantage is performance. A peering connection offers high bandwidth, often exceeding 50 Gbps, and acts like a local connection within the AWS backbone. This minimizes latency, which is crucial for tightly-coupled workloads like the frequent gradient exchanges in large-scale model training.

Transit Gateway, conversely, acts as a cloud router or a regional hub. Each VPC connects to the TGW, which handles routing between all attached VPCs and on-premises networks. This hub-and-spoke model radically simplifies network topology, especially with dozens of VPCs, as you avoid a complex mesh of peering connections. However, all traffic must pass through the TGW, which introduces an extra hop, slightly increasing latency and potentially becoming a bandwidth bottleneck. While TGW bandwidth can scale, it's an aggregated capacity shared across all connections.

For ML, this means TGW is excellent for management and connecting to shared data lakes or logging services, but for the performance-sensitive inner loop of distributed training, VPC Peering is often the superior choice to maximize the bandwidth-delay product and minimize training time.

Bypassing Network Bottlenecks

Massive datasets for ML models are typically stored in services like Amazon S3. A naive approach would be to route this traffic from a private subnet through a NAT Gateway to access the S3 public endpoint. This is inefficient, costly, and adds latency. NAT Gateways have bandwidth limits and incur data processing charges.

The correct architecture utilizes VPC Endpoints, which create private connections between your VPC and supported AWS services, keeping all traffic on the AWS private network. There are two types: Gateway Endpoints and Interface Endpoints. Interface Endpoints leverage a service called to expose services via an Elastic Network Interface (ENI) in your subnet.

FeatureGateway EndpointInterface Endpoint (PrivateLink)
Supported ServicesAmazon S3, DynamoDBMost AWS services, SaaS, internal services
ArchitectureModifies route table with a prefix listDeploys an ENI in your subnet with a private IP
ConnectivityAccessible from the VPC and on-prem (via Direct Connect/VPN)Accessible from the VPC and on-prem (via Direct Connect/VPN)
SecurityVPC Endpoint Policies (IAM-like JSON)Security Groups attached to the ENI, Endpoint Policies
DNSNo DNS integrationIntegrates with DNS, can use private DNS names
CostFreeHourly charge per ENI + data processing fee

For accessing S3, a Gateway Endpoint is a simple, cost-effective choice. It works by adding a target for a specific prefix list to your route table. For other services like Amazon Bedrock or SageMaker, an Interface Endpoint is necessary. It provides a private DNS name that resolves to the private IP of the ENI within your VPC, offering more granular security controls via Security Groups.

Hardware-Level Network Performance

For the most demanding HPC and distributed ML workloads, even a highly tuned TCP stack can be a bottleneck. The (EFA) is a specialized network interface for EC2 instances that provides lower and more consistent latency and higher throughput than traditional TCP/IP transport.

EFA achieves this by supporting custom OS-bypass hardware interfaces. This allows applications using MPI (Message Passing Interface) or NCCL (NVIDIA Collective Communications Library) to communicate directly with the network adapter, avoiding the latency overhead of the kernel's network stack. This is critical for achieving RDMA-like performance for inter-node communication at scale.

Lesson image

To further optimize large data transfers, especially with EFA, you should use Jumbo Frames by increasing the Maximum Transmission Unit (MTU) from the standard 1500 bytes to 9001 bytes. A larger MTU means that each packet can carry more data, reducing the number of packets and the associated processing overhead for both the sender and receiver. This results in higher effective throughput because a smaller percentage of the bandwidth is consumed by packet headers.

Within a cluster placement group, all instances should be configured with the same MTU value to avoid fragmentation, which would negate the performance benefits.

With these advanced networking primitives, you can construct a VPC architecture that eliminates bottlenecks and provides the low-latency, high-throughput environment necessary for state-of-the-art distributed machine learning.

Quiz Questions 1/6

You are designing the network architecture for a large-scale distributed machine learning training job spanning multiple VPCs. The most critical requirement is minimizing latency for frequent gradient synchronization between training nodes. Which networking construct should you prioritize for this specific inter-node communication?

Quiz Questions 2/6

To achieve the highest possible throughput and lowest latency for inter-node communication in a high-performance computing (HPC) cluster, which EC2 network interface should be used?