Skip to content

feat(warmup): add SdkWarmUp for CRaC and Lambda SnapStart priming - #7213

Open
joviegas wants to merge 24 commits into
masterfrom
feature/master/crac_auto_priming_support
Open

feat(warmup): add SdkWarmUp for CRaC and Lambda SnapStart priming#7213
joviegas wants to merge 24 commits into
masterfrom
feature/master/crac_auto_priming_support

Conversation

@joviegas

@joviegas joviegas commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

Customers using Lambda SnapStart or CRaC (Coordinated Restore at Checkpoint) write their own priming code today to warm the SDK request path before a checkpoint. That code is non-obvious: the customer picks an operation, supplies dummy credentials, and suppresses the resulting errors.

SdkWarmUp.warmUp() moves that work into the SDK: it selects the operation for each service, supplies the credentials, and logs failures instead of throwing.

Addresses #5387. Related: #3801, #3236, #3737.

Modifications

Individuals PRs at the bottom.

Public API (sdk-core, software.amazon.awssdk.core.warmup):

@ThreadSafe
@SdkPublicApi
public final class SdkWarmUp {
    public static void warmUp();                                        // every client on the classpath
    public static void warmUp(Class<? extends SdkClient>... clients);   // the clients you name
}

Every service module on the classpath is warmed, including service modules added after this release.

Warm-up runs one synthetic operation per client against an in-memory canned-response HTTP client (dummy credentials, Region.US_EAST_1, endpointOverride(http://localhost)), exercising marshalling, signing, interceptors, and unmarshalling with no network I/O. It then sends one best-effort unauthenticated GET to the regional STS endpoint per HTTP client on the classpath, because DNS, TLS handshake, and certificate-chain paths need a real connection.

Usage

Lambda SnapStart. Lambda snapshots the JVM after the constructor completes, so call warmUp() there:

public class SampleLambdaHandler implements RequestHandler<Order, String> {

    public SampleLambdaHandler() {
        SdkWarmUp.warmUp();          // warms up all AWS SDK clients on the classpath
        // custom initialization code 
    }

    @Override
    public String handleRequest(Order order, Context context) {
        // handler code
    }
}

Standalone CRaC. Call warmUp() before the checkpoint:

public class MyApp implements Resource {

    public MyApp() {
        SdkWarmUp.warmUp();          // warms up all AWS SDK clients on the classpath
        Core.getGlobalContext().register(this);
    }

    @Override
    public void beforeCheckpoint(Context<? extends Resource> context) {
        // close clients and other open file descriptors
    }

    @Override
    public void afterRestore(Context<? extends Resource> context) {
        // recreate clients
    }
}

Warm specific clients when the classpath holds more service modules than the application calls:

SdkWarmUp.warmUp(DynamoDbClient.class, S3AsyncClient.class);

A sync client class warms the sync path and the sync HTTP clients on the classpath; an async client class warms the async path and the async HTTP clients.

Warm-up is opt-in and runs at most once per JVM. Ships in 2.52.0.

Testing

  • Unit tests, and functional tests in the new test/warmup-tests module.
  • JMH benchmarks for first-request latency and warm-up cost.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

License

  • I confirm that this pull request can be released under the Apache 2 license

Individual PRs

  1. feat(sdk-core): Add SdkWarmUpProvider SPI and CannedResponseHttpClient for CRaC auto-priming- #7042
  2. feat(sdk-core): add SdkWarmUp.prime() for CRaC auto-priming- #7056
  3. feat(sdk-core): add sync HTTP-client warm-up to SdkWarmUp.prime() for CRaC priming- #7080
  4. feat(codegen): generate empty SdkWarmUpProvider and META-INF/services registration per service- #7085
  5. feat(sdk-core): add Async HTTP-client warm-up to SdkWarmUp.prime() for CRaC priming- #7092
  6. feat(codegen): generate sync and async client instantiation in ServiceWarmUpProvider.warmUp()- #7101
  7. Add overloaded menthod for SdkWarmUp.prime overloaded to accept speci…- #7130
  8. feat(codegen): add WarmUpOperationSelector to pick the CRaC warm-up operation- #7135
  9. Fix flaky NettyClientAlpnTest by retrying on port-bind race conditions- #7142
  10. (feat:prime/crac) Invoke the selected warm-up operation in the generated SdkWarmUpProvider- #7159
  11. feat(codegen): fill URI/endpoint-bound members for the CRaC warm-up call and warm sync/async clients independently- #7183
  12. test(warmup): Add warm-up tests that auto-cover the generated provider of every service module- #7188
  13. test(sdk-benchmarks): Add cold-start benchmarks for SdkWarmUp priming- #7207
  14. perf(warmup): Warm HTTP clients at most once across targeted prime(ServiceClient.class...) call- #7212
  15. Change mention of "crac" in namespace as "warmup" and change api name "prime" to "warmUp"- #7232
  16. javadocs(warmup): Update SdkWarmUp Javadoc to detail service and HTTP client warm-up after surface review- #7235

joviegas and others added 15 commits June 17, 2026 13:32
…t for CRaC auto-priming (#7042)

* feat(sdk-core): add SdkWarmUpProvider SPI for CRaC auto-priming

* Handled review comments

* Add CannedResponseHttpClient for Crac/Auto priming feature
* feat(sdk-core): add SdkWarmUp.prime() for CRaC auto-priming

* Update review comments

* Update review comments

* test(sdk-core): allowlist ClasspathWarmUpInvoker warn logs in CodingConventionWithSuppressionTest
… registration per service (#7085)

* feat(codegen): generate empty SdkWarmUpProvider and META-INF/services registration per service

* Update javadoc of generated wamrup to make sure we do same as exsiting specs implementation where we donot genrate javadocs for generated interfaces
… CRaC priming (#7080)

* feat(sdk-core): add sync HTTP-client warm-up to SdkWarmUp.prime() for CRaC priming

* Updated tests

* restructure test and comments

* Fixed checkstyle issues

* Handled PR comments

* Update test for blank input

* Update before and after conditions in test
…r CRaC priming (#7092)

* feat(sdk-core): add sync HTTP-client warm-up to SdkWarmUp.prime() for CRaC priming

* Updated tests

* restructure test and comments

* Fixed checkstyle issues

* Handled PR comments

* Update test for blank input

* Update before and after conditions in test

* feat(sdk-core): add Async HTTP-client warm-up to SdkWarmUp.prime() for CRaC priming

* feat(sdk-core): add Async HTTP-client warm-up to SdkWarmUp.prime() for CRaC priming

* Handled PR comments
…eWarmUpProvider.warmUp() (#7101)

* Initialn chages for adding Client instantiation as part of warmup

* reiew 1

* Updated the SdkWarmUpProvider after design discussion

* Nit picks

* handled review comments and made CannedResponseHttpClient and CannedResponseAsyncHttpClient as SdkProtectedApi since they are codegenerated in service modules the architecture test fails if @SdkInternalApi is used in service modules from other modules

* Add warmup-provider-query.java file

* moved the Canned response out of internal package

* update version in pom.xml
#7130)

* Add overloaded menthod for SdkWarmUp.prime overloaded to accept specific clients that needs to be warmedUp

* Updated idempotency testing

* Handled cases when one warmUp provider fails in overloaded method ,so that we can retry for next prime call

* Handle Review comments
…peration (#7135)

* Update to give more preference to operation with outputs

* Handle review comments
…ted SdkWarmUpProvider (#7159)

* Update to give more preference to operation with outputs

* Handle review comments

* feat(codegen): invoke selected warm-up operation in generated SdkWarmUpProvider
…all and warm sync/async clients independently (#7183)

* feat(codegen): fill URI/endpoint-bound members for the CRaC warm-up call and warm sync/async clients independently

* minor update

* Handle review comments
…r of every service module (#7188)

* Add test to make sure all the SDK generated services have warmUp providers and are executed withouut any errors

* Handle review comments

* Add customization clients

* trigerring the codebuild test build to see if the codebuild time increased

* fork test per jvm
…#7207)

* test(sdk-benchmarks): Add cold-start benchmarks for SdkWarmUp priming

* refactor(sdk-benchmarks): Unify duplicate Jetty mock servers into MockHttpServer

* test(sdk-benchmarks): Add cold-start benchmarks for SdkWarmUp priming

* fix checkstyle issue
@joviegas
joviegas requested a review from a team as a code owner August 2, 2026 04:23
joviegas and others added 6 commits August 3, 2026 15:37
…rviceClient.class...) call (#7212)

* test(sdk-benchmarks): Add cold-start benchmarks for SdkWarmUp priming

* refactor(sdk-benchmarks): Unify duplicate Jetty mock servers into MockHttpServer

* test(sdk-benchmarks): Add cold-start benchmarks for SdkWarmUp priming

* fix checkstyle issue

* perf(warmup): Warm HTTP clients at most once across targeted prime call

* Handle review comments
… "prime" to "warmUp" (#7232)

* test(sdk-benchmarks): Add cold-start benchmarks for SdkWarmUp priming

* refactor(sdk-benchmarks): Unify duplicate Jetty mock servers into MockHttpServer

* test(sdk-benchmarks): Add cold-start benchmarks for SdkWarmUp priming

* fix checkstyle issue

* perf(warmup): Warm HTTP clients at most once across targeted prime call

* Handle review comments

* Update after surface api review rename crac to warmup

* Update after surface api review rename crac to warmup

* Update test case name to warmedUp

* Update test case name to warmedUp

* checkstyle fix
@joviegas
joviegas force-pushed the feature/master/crac_auto_priming_support branch from 84a1723 to 56af08a Compare August 9, 2026 22:37
@joviegas joviegas changed the title Auto-Priming Support feat(warmup): add SdkWarmUp for CRaC and Lambda SnapStart priming Aug 10, 2026
@joviegas joviegas added the api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team label Aug 10, 2026
@joviegas
joviegas requested review from alextwoods August 10, 2026 17:37
…#7262)

* refactor(SdkWarmUp): Rename remaining warm-up 'prime' terminology to 'warmUp'

* refactor(SdkWarmUp): Rename the warm-up JMH benchmark methods from prime to warmUp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants