Load balancer, API gateway or CDN?
| Dimension | Load balancers | API gateways | CDNs |
|---|---|---|---|
| Main job | Spread traffic over healthy backends | Authenticate, throttle and route API calls | Serve cached content near users |
| Where it runs | In your region, before your servers | In your region, before your APIs | Hundreds of edge locations worldwide |
| Caches responses | No | Optionally | Yes, that’s its purpose |
| Knows callers and API keys | No | Yes | Only simple rules at the edge |
| Reach for it for | Any service with more than one instance | Public and partner APIs | Static assets and global audiences |
Rule of thumb
A common production path uses all three in a row: the CDN at the edge, then an API gateway or layer-7 load balancer, then your services.
Sources
- ALB docs: What is an Application Load Balancer?
- API Gateway docs: API endpoint types for REST APIs
- API Gateway docs: Cache settings for REST APIs
- API Gateway docs: Usage plans and API keys for REST APIs
- CloudFront docs: How CloudFront delivers content
- Amazon CloudFront features: 750+ points of presence
- Cloudflare: Global network (data centers in 348 cities)
- CloudFront docs: Customize at the edge with CloudFront Functions
- CloudFront docs: Origin types, including load balancers and API Gateway