DEV Community

Durgesh
Durgesh

Posted on

API GW vs ALB

On AWS, that question has two answers: API Gateway or an Application Load Balancer. I built with both to see where each one fits.

π—₯π—Όπ˜‚π˜π—Άπ—»π—΄
API Gateway: path + HTTP method β†’ integration (GET /items β†’ one Lambda, POST /items β†’ another)
ALB: listener rules, mostly by path (/browse β†’ one target group, /insert β†’ another)

𝗩𝗣𝗖
API Gateway: runs on AWS-managed infrastructure. There are no subnets to place it in.
ALB: lives in your VPC, across subnets in at least two Availability Zones.

π—”π˜‚π˜π—΅
API Gateway: API keys, IAM, Cognito, plus Lambda or JWT authorizers for external IdPs
ALB: Cognito or any OIDC-compliant IdP, handled at the listener

π—•π—²π˜€π˜ π—³π—Άπ˜
API Gateway: REST APIs and microservices that need throttling, caching and usage plans
ALB: web apps, container and EC2 backends, longer-running requests (API Gateway's integration timeout defaults to 29 s)

What surprised me: it isn't either/or. API Gateway can sit in front of a private ALB through a VPC Link.

I'm still learning, but now I choose based on routing and auth needs, not habit.

Which one do you reach for first, and why?

Top comments (0)