Amazon EC2 Network Bandwidth Limits: Testing Micro Instance Throughput for Web Servers


2 views

When working with Amazon EC2 micro instances (t2/t3/t4g micro) as web servers for static content, network bandwidth becomes a critical consideration. Unlike traditional VPS providers that often advertise fixed bandwidth caps (e.g., 10MB/s), AWS implements a more complex credit-based system.

For t2.micro instances in particular:

  • Baseline bandwidth: ~0.5 Gbps (62.5 MB/s)
  • Burst capability: Up to 5 Gbps (625 MB/s) for short periods
  • Sustained throughput depends on instance credits

Here's a quick way to test your micro instance's network capacity using curl:

curl -o /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip
# Monitor network usage during test:
aws cloudwatch get-metric-statistics \
  --namespace AWS/EC2 \
  --metric-name NetworkOut \
  --dimensions Name=InstanceId,Value=i-1234567890abcdef0 \
  --start-time $(date -u +"%Y-%m-%dT%H:%M:%SZ" -d "5 minutes ago") \
  --end-time $(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --period 60 \
  --statistics Maximum \
  --region us-east-1

When serving numerous small static files, consider these configurations:

# Nginx example config for high connection count
worker_processes auto;
events {
  worker_connections 4096;
  multi_accept on;
}
http {
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
}

Track your CPU credits (which affect burst bandwidth) with this AWS CLI command:

aws cloudwatch get-metric-statistics \
  --namespace AWS/EC2 \
  --metric-name CPUCreditBalance \
  --dimensions Name=InstanceId,Value=your-instance-id \
  --start-time $(date -u +"%Y-%m-%dT%H:%M:%SZ" -d "1 hour ago") \
  --end-time $(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --period 300 \
  --statistics Average \
  --region your-region

If you consistently exceed ~50MB/s sustained throughput, consider:

  • t3.small: Baseline 1.25 Gbps, burst 5 Gbps
  • t3.medium: Baseline 2.5 Gbps, burst 5 Gbps
  • Add CloudFront CDN to distribute network load

When working with Amazon EC2 micro instances, network performance is tied to the instance type rather than being explicitly capped at a fixed bandwidth value. Unlike traditional VPS providers that impose hard bandwidth limits (e.g., 10MB/s), AWS employs a more dynamic approach.

Micro instances typically fall under the "Low to Moderate" network performance category. While AWS doesn't publish exact bandwidth figures, real-world benchmarks show:

  • Burst capability: Up to 1Gbps during peak periods
  • Sustained throughput: Generally 50-100Mbps for t-series instances
  • Baseline: Around 5Mbps when credits are exhausted

For serving static files, consider these thresholds:

# Example nginx config for optimal static file serving
server {
    listen 80;
    server_name example.com;
    
    location /static/ {
        root /var/www;
        sendfile on;
        tcp_nopush on;
        keepalive_timeout 65;
        
        # Cache control headers
        expires 1y;
        add_header Cache-Control "public";
    }
}

Use CloudWatch to track network metrics:

aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name NetworkOut \
--dimensions Name=InstanceId,Value=i-1234567890abcdef0 \
--statistics Sum \
--start-time 2023-01-01T00:00:00 \
--end-time 2023-01-02T00:00:00 \
--period 3600

If you consistently hit these thresholds, upgrade paths include:

  • t3.small: Moderate network performance
  • c5.large: High network performance (Up to 10Gbps)
  • Network Optimized instances (e.g., c5n.2xlarge with 25Gbps)

Remember that while EC2 doesn't charge for bandwidth within the same region, cross-region and internet egress have costs:

// AWS SDK example to estimate bandwidth costs
const costExplorer = new AWS.CostExplorer();
const params = {
  TimePeriod: {
    Start: '2023-01-01',
    End: '2023-01-31'
  },
  Metrics: ['NetWORK_OUT'],
  Granularity: 'MONTHLY',
  Filter: {
    Dimensions: {
      Key: 'SERVICE',
      Values: ['AmazonEC2']
    }
  }
};