Skip to content

feat: Support CRaC and priming of powertools large messages#2533

Open
David-DAM wants to merge 6 commits into
aws-powertools:mainfrom
David-DAM:feature/support_crac_on_powertools_large_messages
Open

feat: Support CRaC and priming of powertools large messages#2533
David-DAM wants to merge 6 commits into
aws-powertools:mainfrom
David-DAM:feature/support_crac_on_powertools_large_messages

Conversation

@David-DAM

@David-DAM David-DAM commented Jun 14, 2026

Copy link
Copy Markdown

Issue number: Closes #2000

Description of changes:

  • Added CRaC support in powertools-large-messages, following the guide and blogs mentioned on the ticket.
  • Added automatic priming for powertools-large-messages by preloading all the required classes, the list of classes is fetched from the JVM at compile time.
  • Modified Protobuf versions on the powertools-examples-kafka

Checklist

Breaking change checklist

RFC issue #:

  • Migration process documented
  • Implement warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@David-DAM

Copy link
Copy Markdown
Author

closes #2000

@David-DAM David-DAM marked this pull request as draft June 14, 2026 07:48
@David-DAM David-DAM marked this pull request as ready for review June 14, 2026 07:50
@David-DAM

Copy link
Copy Markdown
Author

Hello @phipag, can you review my PR when you have time? Thanks!

@phipag

phipag commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Hey @David-DAM, thank you this looks good on first sight. I will have time to test this very soon and will get back to you here.

In the meantime, did you test it in your own AWS account? E.g. add debug logs to the CRaC hooks and check if they are executed?

@David-DAM

David-DAM commented Jun 18, 2026

Copy link
Copy Markdown
Author

Thanks! Also I don't know how to test it on my own AWS account, is there a guide?

…sages

# Conflicts:
#	examples/powertools-examples-kafka/src/main/java/org/demo/kafka/protobuf/ProtobufProduct.java
#	examples/powertools-examples-kafka/src/main/java/org/demo/kafka/protobuf/ProtobufProductOrBuilder.java
#	examples/powertools-examples-kafka/src/main/java/org/demo/kafka/protobuf/ProtobufProductOuterClass.java
#	powertools-large-messages/src/main/java/software/amazon/lambda/powertools/largemessages/LargeMessageConfig.java
@phipag

phipag commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Hey @David-DAM, apologies for the delay. I am testing now and get back to you in a bit here. The approach is quite manual at the moment:

  • Checkout the PR
  • Deploy a handler in Lambda using the changed code
  • Enable snapstart for the handler
  • Check cloudwatch logs that the priming code gets executed

@phipag

phipag commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Hey @David-DAM, thanks for this. I tested it end to end with SnapStart in my own account and hit one blocker.

The CRaC registration runs in a static initializer, which only fires when the class first loads. In a normal handler the first reference to LargeMessages is inside handleRequest, which runs at invoke time, after the SnapStart checkpoint. So the class never loads during INIT, never registers before the snapshot, and beforeCheckpoint never runs. I confirmed this in CloudWatch: no priming logs across several runs until I referenced the class during INIT.

Please follow the same pattern as our Tracing module: expose a placeholder LargeMessages.init() and document that users call it during INIT, for example in the handler constructor.

public MyHandler() {
    LargeMessages.init();
}

For the docs, add a "SnapStart priming" section to docs/utilities/large_messages.md, mirroring the one in docs/core/tracing.md that renders at Lambda SnapStart priming.

@phipag

phipag commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

By the way: while testing this I found that class preloading was loading 0 classes because ClassPreLoader did not handle the leading whitespace in classesloaded.txt. I made it more robust in #2560.

…sing init method

Add documentation for SnapStar in docs/utilities/large_messages.md
@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

@David-DAM

Copy link
Copy Markdown
Author

@phipag Thanks for the clarification, i have added the changes related to that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Priming for powertools-large-messages

2 participants