jeremydaly / lambda-warmer

A module to optimize AWS Lambda function cold starts
MIT License
525 stars 55 forks source link

Should `invokeCount` not be `invokeTotal`? #65

Open Jimmy89 opened 7 months ago

Jimmy89 commented 7 months ago

If you look at line 106 where is being checked whether a delay must be triggered within the lambda, the code looks at invokeCount, which increases for every invoke. I think this should be invokeCount >= invokeTotal, as otherwise only the first lambda that is called will be delayed, while all up following lambda triggers will have no delay (e.g. invokeTotal = 5, than invokeCount > 1 is true 4 times). In case invokeCount equals invokeTotal no delay is necessary.

Currently, this results into less lambda invokes that are warmed.