Lesson 17 / 26
API Gateway + Lambda Pattern
A serverless backend: HTTP in, functions out.
The pattern
API Gateway exposes an HTTP endpoint, validates and routes each request, then invokes a Lambda function to produce the response — a whole REST API with no servers to manage.
Why teams use it
It fits spiky or low-traffic APIs well: you get automatic scaling, built-in auth integrations, and pay only per request — no idle EC2 fleet running 24/7.
Watch cold starts and timeouts
A Lambda not called recently can have a cold start delay, and every function has a max execution timeout. Not ideal for very long-running or latency-critical hot paths.
Quick check: What is a key benefit of the API Gateway + Lambda pattern for a low-traffic API?
- You pay for servers running 24/7 regardless of traffic
- You pay roughly per request with no idle server cost
- It removes the need for authentication
Answer
You pay roughly per request with no idle server cost — Lambda's pricing is per invocation/duration, so a low-traffic API isn't paying for idle capacity.