jeremydaly / lambda-warmer

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

Alias support: lambda-warmer ignores alias when invoked with a tag and concurrency > 1 #56

Closed Jimmy89 closed 11 months ago

Jimmy89 commented 1 year ago

Setup:

When a lambda with alias is invoked by event bridge with concurrency: 3, it will invoke the alias once. The alias will try to invoke itself another two times. However, the alias that is provided is ignored by the warmer function and therefore the latest tag is called.

I checked whether the target provided to the warmer function contains the alias, which it does. It seems the code does not use this part.

Code snippet:

console.log("I'm invoked",  context.invokedFunctionArn); // <-- contains the first call the function + ":ALIAS" tag.
    if (await warmer(event, { correlationId: context.awsRequestId, target: context.invokedFunctionArn })) {
        return 'warmed'
    }

Update:

after going through the code I notice two things:

  1. The code does not count on aliases being used (because it expects the target to match the function name, adding an alias or version number, being the same as the one executed, will be seen as a 'different' function).
  2. For an alias the Qualifier key must be sent with the InvokeCommand.
naorpeled commented 1 year ago

Hey @Jimmy89

thanks for opening this issue, you're awesome!

I'm on vacation until mid next week, will keep you updated with the progress

naorpeled commented 1 year ago

Hey, just updating that I've been super busy in the last two weeks, will try to get to it towards this weekend. Thanks for your patience ❤️

Jimmy89 commented 11 months ago

@naorpeled Will you have any time soon to address this issue?