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
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
- chore(ci): bump version to 2.3.0 (#2034) by @github-actions[bot]
- chore: bump org.assertj:assertj-core from 3.27.3 to 3.27.4 (#2031) by @dependabot[bot]
- chore: bump software.amazon.awscdk:aws-cdk-lib from 2.208.0 to 2.210.0 (#2030) by @dependabot[bot]
- chore: bump aws.sdk.version from 2.32.18 to 2.32.19 (#2029) by @dependabot[bot]
- chore: bump co.elastic.logging:logback-ecs-encoder from 1.6.0 to 1.7.0 (#2028) by @dependabot[bot]
- chore: bump com.github.spotbugs:spotbugs-maven-plugin from 4.8.4.0 to 4.9.3.2 (#2010) by @dependabot[bot]
- chore: bump com.amazonaws:aws-lambda-java-runtime-interface-client from 2.8.2 to 2.8.3 (#2026) by @dependabot[bot]
- chore: bump github/codeql-action from 3.29.7 to 3.29.8 (#2027) by @dependabot[bot]
- chore: bump org.crac:crac from 1.4.0 to 1.5.0 (#2025) by @dependabot[bot]
- chore: bump aws.sdk.version from 2.32.6 to 2.32.18 (#2024) by @dependabot[bot]
- chore: bump org.junit.jupiter:junit-jupiter from 5.11.1 to 5.13.4 (#2023) by @dependabot[bot]
- chore: bump org.codehaus.mojo:exec-maven-plugin from 3.3.0 to 3.5.1 (#2015) by @dependabot[bot]
- chore: bump aws.sdk.version from 2.32.10 to 2.32.16 (#2014) by @dependabot[bot]
- chore: bump io.github.ascopes:protobuf-maven-plugin from 3.6.1 to 3.7.0 (#2016) by @dependabot[bot]
- chore: bump actions/download-artifact from 4.3.0 to 5.0.0 (#2017) by @dependabot[bot]
- build(deps): bump aws.xray.recorder.version from 2.18.2 to 2.18.3 (#1986) by @dependabot[bot]
- chore(ci): Improve reliability of retries in TracingE2ET (#2018) by @phipag
- chore: bump org.apache.maven.plugins:maven-surefire-plugin from 3.1.2 to 3.5.3 (#2013) by @dependabot[bot]
- chore: bump aws-actions/configure-aws-credentials from 4.2.1 to 4.3.1 (#2011) by @dependabot[bot]
- chore(ci): Make E2E tests compatible with latest CDK lib version. Improve retry implementation. (#2008) by @phipag
- chore: bump github/codeql-action from 3.29.4 to 3.29.5 (#1992) by @dependabot[bot]
- chore: bump software.amazon.awscdk:aws-cdk-lib from 2.162.1 to 2.208.0 (#1990) by @dependabot[bot]
- build(deps): bump org.junit:junit-bom from 5.10.2 to 5.13.4 (#1988) by @dependabot[bot]
- build(deps): bump org.apache.maven.plugins:maven-source-plugin from 3.3.0 to 3.3.1 (#1987) by @dependabot[bot]
- build(deps): bump aws.sdk.version from 2.32.5 to 2.32.10 (#1985) by @dependabot[bot]
- feat: Support CRaC and priming of powertools metrics and idempotency-dynamodb (#1861) by @subhash686
- chore: bump squidfunk/mkdocs-material from
0bfdba4
tobb7b015
in /docs (#1984) by @dependabot[bot] - chore(ci): bump version to 2.2.1 (#1983) by @github-actions[bot]
📜 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