API Gateway
- API Gateway is a gateway that consists of a bunch of Lambda functions that create a serverless learning management system.
- API Gateway is a fully managed service that makes it easy for developers to publish, maintain, monitor, and secure APIs at any scale.
- With a few clicks in the AWS Management Console, you can create an API that acts as a "front door" for applications to access data, business logic, or functionality from your back-end services such as applications running on Amazon Elastic Compute Cloud (Amazon EC2), code running on AWS Lambda, or any web application.
- If your browser is making API calls to API Gateway, then API Gateway is routing down those calls to Lambda.
Architecture of API Gateway
Suppose we got the users operating through phones or laptop makes an API call to API Gateway. API Gateway triggers either a Lambda function or a function inside the EC2.
What is API Caching?
- In Amazon API Gateway, you can enable API caching to cache your endpoint's responses.
- API Caching can reduce the number of calls made to your endpoint and also improve the latency of the requests to your API.
- When API caching is enabled, API Gateway caches the responses from your endpoint for a specified time-to-live period, in seconds. API Gateway responds to the requests by looking up the response from the cache instead of making requests to your endpoint.
Architecture of API Caching
Suppose we have got the users making API calls to API Gateway. API Gateway triggers a Lambda function, and then Lambda function sends back the response to the API Gateway. Now, another user came and makes the same API call to API Gateway then we turn on Caching and time-to-live (TTL). Suppose the TTL is 60 seconds. Therefore, the response is sitting inside the API Gateway for 60 seconds. Now, to serve another user's request, you do not need to call the Lambda function as the response for that request has already been cached. In this way, we can get a much faster response from the end users.
Features of API Gateway
- Cost Effective
It is very low cost and efficient as an API Gateway provides a tiered pricing model for API requests. The price of an API request is as low as $1.51 per million requests, you can also decrease the costs by decreasing the number of requests.
- Scalable
You do not have to worry about having EC2 service or Autoscaling groups responding to API requests. An API Gateway scales automatically.
- Caching and Throttling
Caching is the most important feature of API Gateway. Caching is used to cache the endpoint's responses which improve the latency of requests to your API. It is also a primary factor that determines the price of the service.
You can also prevent the security risks to your API Gateway. If you want to prevent from flooding with the fraud API calls to API Gateway, you can configure throttle service that can throttle requests to prevent attacks.
- Flexible
To implement the API Gateway, you do not have to launch an EC2 instance or setting up the Gateway software. API Gateway can be implemented in few minutes through the AWS Management Console.
- CloudWatch to Connect
An Amazon API Gateway is integrated with the CloudWatch service which is a monitoring service. This tool is used to monitor the metrics of incoming API calls, latency and errors.
- Security
You can authorize access to your APIs. API Gateway is used to verify incoming requests by executing various authorization options such as Lambda function and Identity Access Management service (IAM). An IAM is integrated with a gateway that provides tools such as AWS credentials, i.e., access and secret keys to access an API. A Lambda function is used to verify tokens, and if tokens are successfully verified, then access to an API will be granted.
|