Enabling API Gateway Caching and Throttling

Lab Steps

lock
Logging in to the Amazon Web Services Console
lock
Understanding RESTful APIs
lock
Defining New API Gateway Resources
lock
Creating an AWS Lambda Function Backend
lock
Versioning and Aliasing the Lambda Function
lock
Configuring the API Gateway Backend
lock
Following Best Practices for Versions, Aliases, and Stages
lock
Creating API Keys and Usage Plans
lock
Enabling CORS on API Gateway Resources
lock
Enabling API Gateway Caching and Throttling
lock
Cleaning up API Resources and Lambda Functions
Need help? Contact our support team

Here you can find the instructions for this specific Lab Step.

If you are ready for a real environment experience please start the Lab. Keep in mind that you'll need to start from the first step.

Introduction

You can configure throttling and caching independently for each API Gateway stage. For example, you may want to avoid throttling and caching on your dev stage, and enable them on your prod stage.

Please note that although throttling is free, caching is provided by a custom instance whose size and cost depend on the selected cache capacity (from 500MB to 237GB). Optionally you can encrypt your cache data, set up a time-to-live (TTL) in seconds and require authorization for cache invalidation requests.

You will configure caching and throttling for the prod stage in this Lab Step.

 

Instructions

1. Select the prod stage, check Enable API cache main Settings tab and enter the following values:

  • Cache capacity: 0.5GB
  • Encrypt cache data: Checked
  • Cache time-to-live (TTL): 3600
  • Require authorization: Checked
  • Handle unauthorized requests: Fail the request with a 403 status code

alt

 

2. Scroll down to the Default Method Throttling section and ensure that Enable throttling is checked and accept the default values:

alt

 

3. Click Save Changes at the bottom of the tab.

In case you have special customers and you want to limit their access to your API, you can configure the throttling and daily/weekly/monthly quota on the corresponding Usage Plan.

 

4. Select Usage Plans CloudAcademyPlanDetails Edit and observe the Throttling and Quota sections:

alt
You can set usage plan-level limits here.

 

5. Check Enable quota and enter a quota of 1000 requests per Day before clicking Save:

alt

This configuration will ensure that each individual user (as identified by unique API keys) won't consume your stage/account capacity. Of course, you can monitor and update these configurations at any time, even after creating a Usage Plan or an API Key.

 

Summary

In this Lab Step, you enabled API caching and throttling on the prod stage. You also enabled a quota at the usage plan-level to limit the number of requests authorized by an API Key per day.