Git Product home page Git Product logo

Comments (5)

jeromevdl avatar jeromevdl commented on September 26, 2024 1

Hi,

Thanks for reporting this.

The constructor won't be called in a warmed function, the call to SSM will be done once during cold start. So whatever the maxAge you set, it doesn't really matter, params will remain the same while the function is warmed.

In the handler, with your code I had the following results:
cold start: 3+ seconds (~3400 ms)
warm start: single-digit ms (~2-3 ms)
warm start after 1 min (reload params): ~200-300 ms

I replaced powertools-param with an similar call to ssm:

  • In the constructor:

ssmClient = SsmClient.builder() .httpClientBuilder(UrlConnectionHttpClient.builder()) .credentialsProvider(EnvironmentVariableCredentialsProvider.create()) .region(Region.of(System.getenv(SdkSystemSetting.AWS_REGION.environmentVariable()))) .build();

  • In the handler:

GetParametersByPathResponse params = ssmClient.getParametersByPath(GetParametersByPathRequest.builder().path("/powertools-java/sample").recursive(true).withDecryption(true).build());

And had exactly the same results (few ms difference):
cold start: 3+ seconds (~3300 ms)
warm start: 200-300 ms (each time)

Unfortunately, we cannot improve the call to SSM itself, but thanks to the cache, it reduces the time from 200-300ms to 2-3ms during the time of the cache. Then, you need to find the best TTL for your use case.

from powertools-lambda-java.

deepti-tyagi avatar deepti-tyagi commented on September 26, 2024

Thanks @jeromevdl for taking out some time for this.
Yes, I agree cache does help to improve performance during warm state.

As a workaround, we can also force a cold restart on Lambda function by changing an environment variable whenever there is an update on SSM parameter. We can also avoid additional cold start time using this approach.

My question is, does it impact any existing lambda invocations that are in progress, in any way?

from powertools-lambda-java.

jeromevdl avatar jeromevdl commented on September 26, 2024

Functions currently running are not impacted by an update, they will finish with current version/configuration.

from powertools-lambda-java.

deepti-tyagi avatar deepti-tyagi commented on September 26, 2024

Thanks @jeromevdl for confirming.

from powertools-lambda-java.

pankajagrawal16 avatar pankajagrawal16 commented on September 26, 2024

@deepti-tyagi I believe we can close this issue for now based on above discussion. Thanks for using powertools. Feel free to open an issue in case of any questions/issues/feedback. :)

from powertools-lambda-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.