API Gateway Flashcards
What does API Gateway do
Helps expose Lambda, HTTP & AWS Services as an API
You can have API versioning, authorization, traffic management, and so on
What are some limits to know for API Gateway
29 seconds timeout
10MB max payload size
What are the types of integrations with API Gateway
HTTP
Expose HTTP endpoints in the backend. Example: Put behind a ALB to limit rate or caching or user authentications
Lambda Function
Invoke Lambda to do something
AWS Service
Example start a stepfunction, post a message to SQS
What are the endpoint types in which you can use in deploying your API Gateway
Edge-Optimized (Default): For global clients, requests are routed through cloudfront edge locations (closer to the users) this reduces the latency experienced by clients when making API requests because the data doesn’t have to travel as far.
Regional: For clients in the same region
Private: Can only be accessed from your VPC using an endpoint and a resource policy
How can you reduce the number of calls made to your backend
By caching API responses. The Default TTL is 300secs
You can encrypt the cache
And the capacity of the cache is between 0.5GB to 237GB
What does a 4xx type API Gateway Error mean
400: Bad Request
403: Access Denied, WAF filtered
429: Quota exceeded, Throttle
What does a 5xx type API Gateway Error mean
502: Bad Gateway Exception (Backend Server Unavailability, timeout or Backend Server Error)
503: Service Unavailable Exception (API gateway understands the request, cannot connect to the backend)
504: Integration Failure (Usually timeout. It did not receive a response in time)
What are three ways you can do authentication for API Gateway
IAM based access
Lambda Authorizer
Cognito User Pools
Explain API Gateway Logging capability
Use CloudWatch Logs by stage to log full request and responses
You can send API Gateway Access Logs
You can send logs directly to Kinesis Data Firehose
Explain API Gateway Metric capability
Use cloudwatch metrics by stage
Some of the CW metrics are:
IntegrationLatency
Latency
CacheHitCount
CacheMissCount
Explain API Gateway Tracing capability
You can use X-Ray to enable tracing to get extra information about requests in API Gateway
What is the API Gateway Usage Plan
API Gateway usage plan is a feature to enable if you want to make an API available to your customers. The Usage Plan defines the following:
Who can access your deployed API stages and methods
How much and how fast they can access them
Uses API keys to identify API clients and meter access
Configure throttling and quota limits per client
What are API keys and how are they used in API gateway
API keys are used to identify your customers. They are alphanumeric string values that are used to distribute to your customers. You can use with usage plans to control access. You can set throttling limits and quota limits at the key level
API Gateway has a feature called WebSocket API. What is it
It is a two-way interactive communication between a user browser and a server.
Server can push information to the client.
It is often used in chat applications, games, financial trading platforms etc.