rony yosef
rony yosef

Reputation: 1

Aws lambda authorizer - cache inside lambda decorator

How can I prevent multiple lambda authorizers triggered at the same time by api gateway from the same user? It is happening because I’m doing multiple calls from the UI at the same time. The reason that I want to prevent the behavior is because I’m caching mechanism inside the lambda authorizer which I’m not really enjoying from because of that behavior

thanks everyone for a answer about this or any suggestions

Upvotes: 0

Views: 363

Answers (1)

Matan Benita
Matan Benita

Reputation: 321

Lambda authorizer cache is not distributed between different API Gateways. If you are using the same lambda function between all API-GWs then you should strive to make your lambda be as slim as possible and then you will be able to "enjoy" with your cache solution. I saw lambda authorizers that once the got hot, their runtime took about 2ms!!. so this is something that definitely can take advantage of. My suggestions are:

  1. Avoid lambda layers. keep the lambda slim.
  2. Use Lru cache. this will make sure your memory doesn't choke your lambda.

Upvotes: 0

Related Questions