Upgrade to Pro — share decks privately, control downloads, hide ads and more …

From Spring Native to Spring Boot 3 at Spring I...

From Spring Native to Spring Boot 3 at Spring I/O 2023

Moritz and Sébastien will tell you the story behind the support of compiling Spring Boot application to native executable, how the support evolved from the Spring Native beta announcement to the builtin support provided in Spring Boot 3 GA and how the Spring team grew the collaboration with the GraalVM team to improve the native support for the whole JVM ecosystem.

It will also be the opportunity to provide a detailed overview of the brand new native support provided by Spring Boot 3 based on Spring Framework 6 and related portfolio projects like Spring Data or Spring Security : Developer Experience, instant startup time, reduced memory footprint, Ahead Of Time transformations, scope of the compatibility. We will cover all those topics and more!

Moritz Halbritter

June 23, 2023
Tweet

More Decks by Moritz Halbritter

Other Decks in Programming

Transcript

  1. Why compile to native? Instant startup Milliseconds for native instead

    of seconds for the JVM No warmup Peak performance available immediately Low resource usage Lower memory footprint and no JIT compilation Reduced attack surface Closed world of dependencies with explicit reflection and serialization Compact packaging Smaller container easier to deploy
  2. Use cases for native images JVM likely better Assess Recommended

    Low memory and CPU Scale to zero Function as a Service Microservices Backoffices Container image distribution Very frequent deployment High traffic website Unsupported dependency Big monolithic application Huge memory and CPU Agent-based observability Kubernetes
  3. It got official with Spring Boot 3 Spring Boot 3

    introduces official support for compiling applications to native executables and supersedes Spring Native.
  4. GraalVM 22.3 baseline • GraalVM versions support policy: • Currently

    support GraalVM 22.3 • Upcoming GraalVM 23.0 compatibility ◦ Better performance ◦ Compatibility improvements ◦ Bundles ◦ Experimental JMX support ◦ …
  5. VMware Spring Runtime adds end-to-end native support • VMware and

    Bellsoft now have a support agreement that provides end-to-end native support to VMware Spring Runtime customers • Bellsoft Liberica NIK (based on the GraalVM Community Edition) and Liberica JDK are used in native Buildpacks • Consistent with the JVM side where Liberica JDK is used • Fixes and enhancements will be contributed upstream to GraalVM
  6. Library support based on GraalVM reachability metadata • Native image

    configuration for JVM libraries • Initially a GraalVM and Spring driven effort • Guidelines on how to craft native configuration ◦ Runtime initialization by default ◦ No build-time initialization ◦ Reachability based native configuration ◦ Mandatory native testing
  7. Spring Boot 3 AOT and native support overview Native Build

    Tools GraalVM Spring Boot 3 AOT and native integration in Boot plugins AOT transformation engine Spring Framework 6 Paketo Buildpacks Native Buildpack AOT plugins Native documentation Spring portfolio (Data, Security, etc.) AOT transformations Native hints native-image compiler Reachability metadata repository
  8. Native compilation with Spring App compiled Compiled sources Resources AOT

    is done Compiled sources Resources AOT sources Native image config Compiled AOT sources Native binary Native application :generateAotSources + :aotClasses :nativeCompile Application Jar AOT optimized app :bootJar AOT classes
  9. Two way of building native executables Native Build Tools •

    Started as a collaboration between Spring and GraalVM team, and recently the Micronaut team has joined • Application compilation and testing support • Requires local GraalVM native-image compiler • Produces a native executable ◦ Linux (x64, ARM) ◦ MacOS (x64, ARM) ◦ Windows (x64)
  10. Two way of building native executables Buildpacks • Container based

    native builds based on Buildpacks • Application compilation support • Requires Docker but no local GraalVM installation • Produces a Linux container image ◦ x64 is supported ◦ Official ARM support work in progress
  11. Two ways of adding observability Using JVM agents • Some

    agents work, when using the agent at build time ◦ Fixed configuration! Using Micrometer Tracing • First class support in (native) Spring
  12. Actuator is working in a native image > curlie :8080/actuator/prometheus

    process_cpu_usage 0.0 process_files_max_files 524288.0 executor_queued_tasks{name="applicationTaskExecutor",} 0.0 jvm_classes_unloaded_classes_total 0.0 tomcat_sessions_active_current_sessions 0.0 tomcat_sessions_created_sessions_total 0.0 executor_pool_core_threads{name="applicationTaskExecutor",} 8.0 process_uptime_seconds 43.158 system_load_average_1m 4.39404296875 jvm_threads_peak_threads 18.0 disk_free_bytes{path="/home/moe/Downloads/demo/.",} 1.24508004352E11 executor_pool_size_threads{name="applicationTaskExecutor",} 0.0 tomcat_sessions_rejected_sessions_total 0.0 tomcat_sessions_expired_sessions_total 0.0 executor_pool_max_threads{name="applicationTaskExecutor",} 2.147483647E9