Skip to main content

Version: 2.13.2304

Rate Limiting

This article will guide you on how to configure rate limiting and throttling for APIs using the limit-count plugin on the API7 dashboard, and how to validate the results.

Prerequisites

  1. Install API7 Enterprise
  2. Designing APIs and Publishing APIs to API7 Gateway.

Create a Plugin Template

Refer to the documentation on Create Plugin Template.

In 9. Enable the required plugins by clicking the corresponding Enable button, select the limit-count plugin.

In 11. Edit the plugin parameters in the Configuration Raw Data, enter the following configuration:


{
"count": 3,
"time_window": 60,
"key_type": "var",
"rejected_code": 503,
"rejected_msg": "Too many request",
"policy": "local",
"allow_degradation": false,
"show_limit_quota_header": true
}

In this example, we restrict the API bound to this plugin to be accessed only 3 times within 60 seconds. If the limit is exceeded, a 503 status code is returned.

Apply the Plugin Template to the API

Taking CreateProduct as an example.

Refer to the documentation on Configure API.

In 9. Edit the properties of the API, modify the plugin template to the one created in the previous step that includes the limit-count plugin.

Validate

Sending API requests four times consecutively:


curl -X POST -d '{"name": "iPhone 13 Pro", "price": 999.99}' -H 'HOST: test.com' -v http://${API7_GATEWAY_ADDRESS}/products

The first three requests receive normal responses, while the fourth request returns a 503 status code.

Wait for 60 seconds, then use the curl command to send another API request,you will see the expected API response.


{
"id":1
}


API7.ai Logo

API Management for Modern Architectures with Edge, API Gateway, Kubernetes, and Service Mesh.

Product

API7 Cloud

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

Copyright © APISEVEN Ltd. 2019 – 2024. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the

Apache Software Foundation