-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Support for native-image compilation #335
Comments
Totally support this issue! |
Please check https://catalog.workshops.aws/java-on-aws-lambda/en-US/01-migration/03-alternatives/graalvm for an example. Will get that added to the docs. |
Now that we have Spring Boot 3 Support (see #487, which I tested and it works really nice so far! Awesome work!), maybe it's time to revive this issue? I can use Spring Boot Native to create Custom Images; I can use the serverless-java-container lib to "bridge" Api Gateway Events into Spring ... But I can't get my head around how to combine these two. Is this already possible? Or would it need some kind of special Custom Runtime "Event Loop" thing, similar to this ? (That would call SpringBootLambdaContainerHandler.proxy(...) when it polls a new event) |
@fsomme2s One critical difference between native image support for spring via "Spring Cloud Function" and aws-serverless-java-container is the runtime. You can use spring boot 3 to compile to a native image, create a custom runtime and use that to make a simple function with the code already provided by Spring Cloud Function. But this will not correctly proxy API Gateway requests. The reason why aws-serverless-container does not work out of the box is that it assumes to be running in a java runtime. When this happens, the invocation is handled by the AWS Platform which executes a java method somewhere. This does not work with a custom runtime where you have to listen for invocations by calling out to an API. The SAM template in the spring boot 3 example uses the following for runtime invocation: Handler: com.amazonaws.serverless.sample.springboot3.StreamLambdaHandler::handleRequest From my understanding, this is the part that has to be changed. What does work is the custom runtime integration that is provided by Spring Cloud Function's AWS adapter. ( I don't think it would be too difficult to create a runtime inializer inspired by CustomRuntimeInitializer and CustomRuntimeEventLoop. However, it seems that it is quite possible Spring Cloud Function already supports this since very recently. I haven't confirmed but there is https://github.com/spring-cloud/spring-cloud-function/blob/main/spring-cloud-function-adapters/spring-cloud-function-adapter-aws-web/src/main/java/org/springframework/cloud/function/adapter/aws/web/WebProxyInvoker.java |
@deki I'm having trouble integrating aws-serverless-java-container-springboot3 with Graalvm and a custom lambda runtime/handler. Has anyone successfully managed to do this? Is the anyway to make it work? |
@deki That's great, Thank you for the amazing work! |
…rsions for sample
…tln in favor of proper logging
…andler should use same processing logic
…y to avoid infrequent CPU features error
…on-serverless-web 4.0.6 release
#739 has been merged and will be part of the next release. We've also added a sample: https://github.com/aws/serverless-java-container/tree/main/samples/springboot3/pet-store-native |
Scenario
As the Spring framework adds support for GraalVM's native image tool, we should explore making it easy to compile SpringBoot applications and execute them as a custom runtime in AWS Lambda
This issue serves as a tracker for this project to make design decisions and collect feedback on the implementation
The text was updated successfully, but these errors were encountered: