https://serverless-stack.com/ logo
#help
Title
# help
k

Karolis Stulgys

04/28/2022, 9:30 AM
How do I limit calls per minute to my api endpoint/lambda?
k

Karolis Stulgys

04/28/2022, 10:58 AM
Thanks! but what does these numbers mean?
Copy code
defaultThrottlingRateLimit: 2000,
  defaultThrottlingBurstLimit: 100,
can I set throttling conditionally? i.e based on who's requesting
a

Arpad

04/28/2022, 11:51 AM
Haven't really worked with throttling, I guess you can create a UsagePlan with cdk and add it to each functions as needed. As for the "per user" throttling thing, I think you need something custom for that, but I am not sure. https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.UsagePlan.html#methods
f

Frank

04/28/2022, 5:35 PM
Thanks @Arpad!
@Karolis Stulgys
sst.Api
uses API Gateway HTTP API behind the scene and it doesn’t support requester based throttling.
sst.ApiGatewayV1Api
uses the API Gateway REST API behind the scene, and it supports Usage Plan and Api Key as @Arpad suggested.
The latter is more feature rich, but a bit more expensive and a bit slower.