AWS API Gateway provides a way to rate limit requests using the Usage plan for different users.
But the rate limit is applicable for all end-points.
So, if I have a GET
request and another POST
request endpoints, can I set different limits for the GET
request and separate limit for the POST
requests?
Example:
GET request end-point
https://aws.api.gateway/v1/get_data <- set rate limit to 10,000
POST request end-point
https://aws.api.gateway/v1/post_data <- set rate limit to 100
The POST requests is a costly operation, hence I would want to limit the number of requests by a certain user whereas allow for a large number of GET
requests.
Requirement is basically to have 2 different rate limits for 2 different end-points.
API Gateway provides a feature to limit the number of requests a client can make per second (rate) and per day/week/month (quota). Rate limiting is very useful to protect your system from resource starvation caused by a client flooding your system with requests.
AWS WAF checks the rate of requests every 30 seconds, and counts requests for the prior five minutes each time. Because of this, it's possible for an IP address to send requests at too high a rate for 30 seconds before AWS WAF detects and blocks it. AWS WAF can block up to 10,000 IP addresses.
The burst limit defines the number of requests your API can handle concurrently. The rate limit defines the number of allowed requests per second.
You can have two different rate limits for two different endpoints.
If you go to your gateway's stages and click one of the endpoints, you'll see something like this...
So, by default all endpoints use your stage-level rate limits. But you choose "Override for this method", you'll get this...
You can then set your method-level rate limit for that HTTP method.
Reference: http://docs.aws.amazon.com/apigateway/latest/developerguide/stages.html#how-to-stage-settings
- To override the stage-level throttling for individual methods, expand the stage under the Stages secondary navigation pane, choose a method of interest, and, back in the stage editor, choose Override for this method for Settings. In the Default Method Throttling area, select appropriate options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With