AWS · Front-End Web and Mobile

Amazon API Gateway

A managed front door for APIs: it receives HTTP and WebSocket requests, applies auth and throttling, and forwards them to backends.

On the SAA-C03 exam listAPI managementServerless

What it is and what problem it solves

Amazon API Gateway lets you publish, secure and monitor APIs without running servers. Clients call the API; API Gateway authenticates the request, applies throttling and optional caching, and forwards it to a backend: a Lambda function, an HTTP service, or another AWS service.

It offers three kinds of API. REST APIs have the most features (usage plans and API keys, request validation, caching, WAF integration, private endpoints). HTTP APIs are simpler and lower cost, with JWT authorisers and Lambda or HTTP backends. WebSocket APIs keep two-way connections open for chat and live updates.

Clientsweb, mobileAPI Gatewayauth · throttling · caching · WAFHTTPSCognito / Lambda authorizerLambdaserverless backendVPC link → ALB/NLBprivate servicesAWS servicee.g. SQS, DynamoDB
API Gateway in front of Lambda, private services through a VPC link, or AWS services directly

When to use it

  • You expose a serverless backend (Lambda) over HTTPS without managing a web server.
  • You need built-in authentication (IAM, Cognito, JWT, or a Lambda authoriser), throttling and per-client usage plans.
  • You want one managed entry point in front of several backend services.
  • You need WebSocket connections without running your own connection servers.

When to avoid it

  • Long-running requests: the integration timeout is short (about 30 seconds); return quickly and continue asynchronously, or use another design.
  • Large uploads or downloads: the payload limit is 10 MB; use S3 pre-signed URLs for big files.
  • Very high steady traffic to a simple backend: an Application Load Balancer in front of containers or instances is often cheaper per request.
  • Global content caching: that is CloudFront's job, which can sit in front of an API.

Scaling model and bottlenecks

API Gateway scales automatically to your account's throttle limit, which is a requests-per-second rate with a burst allowance, shared across the APIs in a Region. A flood from one API can throttle your other APIs, so use per-stage, per-method and usage-plan throttles to protect the important ones. Your backend must also scale to match.

Performance, latency and throughput

REST APIs offer an optional cache that cuts calls to the backend and lowers latency for repeatable requests. HTTP APIs add less overhead than REST APIs. For clients across the world, edge-optimised endpoints or CloudFront in front reduce connection time.

Limits and quotas

Two limits shape designs most often: the integration timeout, and the maximum payload size. Check which API type you use, because they differ.

ItemValueContextSource
Integration timeout, REST API 29 seconds by default
Can be raised with a quota request
Can be raised above 29 seconds for Regional and private APIs only, which may require lowering your Region-level throttle quota. Source
checked
Integration timeout, HTTP API 30 seconds
Fixed limit
Source
checked
Payload size, REST and HTTP APIs 10 MB
Fixed limit
Source
checked
Account-level throttle per Region 10,000 requests per second, with a burst bucket of 5,000
Can be raised with a quota request
Shared across HTTP, REST and WebSocket APIs in the Region; the burst value is set by the service. Some Regions have lower defaults. Source
checked
WebSocket message payload size 128 KB
Fixed limit
Source
checked
WebSocket connection duration 7,200 seconds (2 hours)
Fixed limit
Source
checked
WebSocket idle connection timeout 600 seconds
Fixed limit
Source
checked

Quotas and limits change. Check the linked source before designing around a number.

Cost model

What you pay for

  • REST and HTTP APIs: a charge per million API calls received, with HTTP APIs priced lower than REST APIs.
  • WebSocket APIs: per million messages (counted in 32 KB increments) and per connection-minute.
  • Optional REST features: caching billed per hour by cache size.
  • Data transfer out, billed per GB.
  • Backends and authorisers (Lambda, for example) bill separately.

Where it is cost-efficient

Low and spiky traffic with a Lambda backend, where you pay per request and nothing when idle. HTTP APIs suit most simple proxy use cases at lower cost.

Where costs grow

  • Sustained high request volume, where per-request pricing can exceed the cost of a load balancer.
  • A REST API chosen for features you do not use, when an HTTP API would do.
  • Large responses, because data transfer out is billed.
  • Idle WebSocket connections that stay open.

Cost controls and common surprises

Pick HTTP API unless you need REST-only features, enable caching only where it reduces backend cost, compress responses, and use usage plans or throttles to stop runaway clients.

Prices differ by Region and change over time; see the pricing page linked under Sources.

Security

Controls the service provides

  • Authentication and authorisation: IAM, Amazon Cognito user pools, JWT authorisers (HTTP APIs) and Lambda authorisers.
  • TLS for all endpoints, custom domains with ACM certificates, and optional mutual TLS.
  • Throttling, usage plans and API keys to limit abuse and meter clients (API keys are for metering, not for authentication).
  • AWS WAF can be attached to REST APIs to block common attacks.
  • Private APIs are reachable only from inside a VPC through an interface endpoint.

What you configure

Always put an authoriser on non-public routes, restrict who can deploy and change APIs, validate request bodies, use WAF for internet-facing REST APIs, and give each backend integration role the least privilege it needs.

Logging and monitoring

Access logs and execution logs go to CloudWatch Logs, with metrics for latency and errors; X-Ray tracing is available; CloudTrail records configuration changes.

Related security services

Cognito, IAM, WAF, Shield, ACM, CloudFront and CloudWatch.

Shared responsibility

AWS operates and scales the service. You choose authentication, secure the backend, and manage keys and certificates.

Availability, backup and failure behavior

API Gateway is a regional service that runs across multiple Availability Zones. For multi-Region resilience, deploy the API in two Regions behind a Route 53 failover or latency record with a custom domain. Make backend calls resilient with timeouts and retries on the client, since the gateway returns an error rather than waiting past its integration timeout.

Common service combinations

API Gateway to Lambda (serverless APIs), to a private ALB or NLB through a VPC link, or directly to DynamoDB, SQS or Step Functions; Cognito for sign-in; CloudFront and WAF in front; DynamoDB behind.

Business application examples

  • A mobile app calls a serverless API that reads and writes DynamoDB through Lambda.
  • A partner API with usage plans that meter and limit each partner's requests.
  • A live dashboard that pushes updates to browsers over a WebSocket API.

Exam cues and common confusions

  • Serverless HTTP front end for Lambda: API Gateway.
  • Throttle or meter clients by key: usage plans and API keys. Do not use API keys as the only security.
  • Cut backend calls for repeatable requests: REST API caching.
  • Two-way real-time messages: WebSocket API.
  • API only reachable from a VPC: a private API with an interface endpoint.
  • Request longer than the timeout or larger than 10 MB: redesign (asynchronous work, S3 pre-signed URLs).

Related

Courses and lessons

Services, comparisons and patterns

Sources

Independent study material, not affiliated with or endorsed by Amazon Web Services. AWS and service names are trademarks of Amazon.com, Inc. or its affiliates.

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake