Interview Prep/Real-World Interview/Cloud provider issues

Services in private subnets randomly fail outbound calls to a partner API; CloudWatch shows `ErrorPortAllocation` rising on the NAT gateway.

AdvancedTroubleshootingCloud provider issues
Answer

Likely causes → NAT gateway source-port exhaustion. A NAT gateway IP supports about 55,000 simultaneous connections to one destination IP and port. Many pods opening new short-lived connections to the same partner endpoint (no keep-alive, no pooling) run out of ports.

Diagnose →

aws cloudwatch get-metric-statistics --namespace AWS/NATGateway --metric-name ErrorPortAllocation \
  --dimensions Name=NatGatewayId,Value=$NAT --statistics Sum --period 60 \
  --start-time $(date -u -d '-1 hour' +%FT%TZ) --end-time $(date -u +%FT%TZ)

Also check ActiveConnectionCount and ConnectionAttemptCount, and VPC Flow Logs for top destinations.

Fix → Reuse connections (HTTP keep-alive, connection pools), and add secondary IPs to the NAT gateway (each adds another ~55k ports per destination), or spread traffic across more NAT gateways.

Prevent → Alarm on ErrorPortAllocation > 0, use VPC endpoints for AWS services so they bypass NAT, and review clients that open a new connection per request.

All Real-World Interview questions Roadmap: Interview readiness

More on Cloud provider issues