Skip to content
A plugin for the Serverless framework which configures throttling for API Gateway endpoints.
JavaScript
Branch: develop
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Using mocha-circleci-reporter Nov 15, 2019
.vscode Added basic functionality, settings and some tests for settings Nov 10, 2019
src Fixed issue where function could not be found Dec 6, 2019
test
.gitignore Added basic functionality, settings and some tests for settings Nov 10, 2019
.npmignore can't find a way to disable throttling via API so removed config whic… Nov 24, 2019
README.md Improved readme Nov 24, 2019
package-lock.json version++ Dec 6, 2019
package.json version++ Dec 6, 2019

README.md

serverless-api-gateway-throttling

CircleCI

Intro

A plugin for the Serverless framework which configures throttling for API Gateway endpoints.

Why?

When you deploy an API to API Gateway, throttling is enabled by default. However, the default method limits – 10,000 requests/second with a burst of 5000 concurrent requests – match your account level limits. As a result, ALL your APIs in the entire region share a rate limit that can be exhausted by a single method. Read more about that here.

This plugin makes it easy to configure those limits.

Good to know

  • if custom throttling settings are defined for an endpoint with HTTP method ANY, the settings will be applied to all methods: GET, DELETE, HEAD, OPTIONS, PATCH, POST and PUT.

Examples

plugins:
  - serverless-api-gateway-throttling

custom:
  # Configures throttling settings for all http endpoints
  apiGatewayThrottling:
    maxRequestsPerSecond: 1000
    maxConcurrentRequests: 500

functions:
  # Throttling settings are inherited from global settings
  update-item:
    handler: rest_api/item/post/handler.handle
    events:
      - http:
          path: /item
          method: post

  # Requests are throttled using this endpoint's throttling configuration
  list-all-items:
    handler: rest_api/items/get/handler.handle
    events:
      - http:
          path: /items
          method: get
          throttling:
            maxRequestsPerSecond: 2000
            maxConcurrentRequests: 1000

  # Requests are throttled for both endpoints
  get-item:
    handler: rest_api/items/get/handler.handle
    events:
      - http: # throttling settings are inherited from global settings
          path: /item/{itemId}
          method: get
      - http:
          path: /another/item/{itemId}
          method: get
          throttling:
            maxRequestsPerSecond: 2000
            maxConcurrentRequests: 1000
You can’t perform that action at this time.