Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rate limit AWS API gateway endpoint

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.

like image 451
Vaulstein Avatar asked Sep 07 '17 16:09

Vaulstein


People also ask

Does API gateway rate limit?

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.

Does AWS have rate limiting?

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.

What is rate and burst in API gateway?

The burst limit defines the number of requests your API can handle concurrently. The rate limit defines the number of allowed requests per second.


1 Answers

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...

Default settings

So, by default all endpoints use your stage-level rate limits. But you choose "Override for this method", you'll get this...

Override settings

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

  1. 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.
like image 104
Noel Llevares Avatar answered Sep 29 '22 16:09

Noel Llevares