Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warmup #72

Closed
ghost opened this issue Sep 13, 2017 · 8 comments
Closed

Warmup #72

ghost opened this issue Sep 13, 2017 · 8 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Sep 13, 2017

Hi,
Thanks for this very useful project.
I've add the warmup plugin with the prewarm option.
I've seen the integration in the warmup plugin of the alias var.

I was wondering if it's possible to warmup the new version of the lambda deployed before the alias is changed to point on it.
The aim is to avoid lambda timeout after the alias is changed because of the long coldstart period.

Any ideas ?
Thanks,

Fred.

@HyperBrain
Copy link
Member

HyperBrain commented Sep 13, 2017

Hi @fmuracciole, the final aliased Lambda has to be warmed, because otherwise a different instance of the lambda would be spun up, and then the aliased one.
So imo pinging a different qualifier (like $LATEST) which is natively deployed by Serverless first will not have any effect, because the alias plugin creates a new version.

The alias option in the warmup plugin is very important, because the CW event that runs the warmup has to trigger the correct alias that is deployed.

I need to have a look at the prewarm option. Maybe it is possible to add some handling either in the alias plugin or in the warmup plugin to make them run better.

Can you additionally check if the order of the plugins in serverless.yml matches the one described in my README? Just to be sure ;-)

BTW: We also use both plugins at work, but I'm sure not with prewarm.

@ghost
Copy link
Author

ghost commented Sep 13, 2017

Thanks for your quick response,

I've respected the order you said in the README :
I'm using java lambdas with serverless 1.21.1

`frameworkVersion: ">=1.12.0 <2.0.0"

plugins:

  • serverless-plugin-warmup
  • serverless-aws-alias
    `

The warmup lambda is created, invocations are made at the beginning BUT i can't see any schedule trigger on it ... maybe a warmup bug.

I understand the problem of differents versions warmed, but a call to a specific version is not possible ? i.e. the future one , instead of calling the alias ?

@HyperBrain
Copy link
Member

Ok. now I got it. I'll have to check the warmup plugin. In case of prewarm it should call the (not yet aliased but already deployed) new function version instead of the alias (which would trigger the old one) once, to warm it up. Afterwards the alias plugin will switch the alias to the new version.

As I see it, this can be only fixed in the warmup plugin, so that SERVERLESS_ALIAS is used as is to configure the CW rules correctly, but only during deployment (when the prewarm action in the plugin is started) it should use the function version from Serverless.

I'll try to get a fix ready for the warmup plugin (maybe tomorrow or on Friday). Do you know if there is already an issue opened there?

@ghost
Copy link
Author

ghost commented Sep 13, 2017

Great ! 👍
No issue opened yet for the warmup plugin

@HyperBrain
Copy link
Member

Sorry that there was no action here yet - I was quite loaded with work the last days. I will take care of this later this week.

@HyperBrain
Copy link
Member

I found the issue. For the prewarmup ping the warmup plugin uses process.env.SERVERLESS_ALIAS. This environment variable is currently only set in the AWS environment (function environment) but not in the Serverless process while deploying.

    const params = {
      FunctionName: this.warmup.name,
      InvocationType: 'RequestResponse',
      LogType: 'None',
      Qualifier: process.env.SERVERLESS_ALIAS || '$LATEST',
      Payload: JSON.stringify({ source: 'serverless-plugin-warmup' })
    }

    return this.provider.request('Lambda', 'invoke', params)
    ...

I'll provide a fix here, because otherwise the warmup plugin had to access the alias option which it should not be aware of semantically.

@HyperBrain
Copy link
Member

Released with 1.5.1

@ghost
Copy link
Author

ghost commented Nov 25, 2017

Thanks a lot for the fix !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant