Skip to content

v2.3.0

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 13 Aug 08:40
· 1 commit to refs/heads/main since this release

Summary

This release introduces Lambda SnapStart priming techniques to both the powertools-metrics and powertools-idempotency utilities, optimizing cold start performance for customers using SnapStart.

We've also updated dependencies across the library, with the most notable change being the removal of AWS SDK v1 dependency from the powertools-tracing utility, aligning with the recent AWS X-Ray SDK update (Release 2.19.0).

⭐️ Thanks to @subhash686 for contributing the SnapStart priming techniques!

⚡ Lambda SnapStart Priming

Lambda SnapStart AWS Docs

SnapStart reduces Lambda cold start times by taking a snapshot of your initialized function and reusing it for subsequent invocations. We can run custom code before the snapshot is taken to initialize code that would otherwise be initialized at runtime. This process is referred to as "priming", and this is achieved using Java runtime hooks from the open source CRaC (Coordinated Restore at Checkpoint) project.

The following example shows how to prime an AWS S3 client:

import org.crac.Core;
import org.crac.Resource;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;

import software.amazon.awssdk.services.s3.S3Client;

public class Handler implements RequestHandler<String, String>, Resource {

    private final S3Client s3Client = S3Client.create();

    public Handler() {
        Core.getGlobalContext().register(this);
    }

    @Override
    public String handleRequest(String input, Context context) {
        // Business logic using s3Client
        return "Hello SnapStart" + input;
    }

    @Override
    public void beforeCheckpoint(org.crac.Context<? extends Resource> context) {
        // Will be called before SnapStart takes the snapshot
        s3Client.listBuckets();
    }

    @Override
    public void afterRestore(org.crac.Context<? extends Resource> context) {
        // Reinitialize after restore
    }
}

🧑‍💻 Want to contribute? Learn more about implementing priming techniques in our Priming documentation for contributors. We're actively working on extending SnapStart priming support across all utilities and are looking for contributors to help with this effort. Check out our project issues to see how you can get involved!

Changes

📜 Documentation updates

  • docs(examples): Add Bazel example for core utilities (#2022) by @phipag
  • docs(examples): Add Logging and Tracing to idempotency example with correct config (#1993) by @phipag

🐛 Bug and hot fixes

  • docs(examples): Enable end to end tracing for SQS batch example. (#1995) by @phipag

This release was made possible by the following contributors:

@phipag, @subhash686