# API Gateway + Lambda Pattern — AWS Fundamentals: Core Services for Cloud Beginners

Source: https://www.skillbyai.com/en/aws/aws-api-gateway-lambda

> Build a serverless HTTP backend with API Gateway and Lambda, and understand cold starts and limits.

## 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.

**Quiz:** What is a key benefit of the API Gateway + Lambda pattern for a low-traffic API?

- [x] You pay roughly per request with no idle server cost
- [ ] You pay for servers running 24/7 regardless of traffic
- [ ] It removes the need for authentication
- [ ] You must run servers 24/7

*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.
