GraalVM Native Image - Low
Footprint Java in the Cloud
JavaThrough the Looking Glass
Kris Foster
Principal Product Manager, GraalVM
What is it?
• Java Runtime (JDK11, JDK17)
• New Fast & Efficient JIT Compiler
• Applications => Native Executables
• Multi-Language
• Enterprise / Community
Why should I care?
• Java Runtime - Improved performance
• Applications => Native Executables
• Fast start-up, low footprint
“The best way to explain it is to do it.”
GraalVM
Copyright © 2022, Oracle and/or its affiliates
2
What is it and why should I care?
Java Apps in Containers
3 Copyright © 2022, Oracle and/or its affiliates
Simple Spring Boot, Rest API Application
Credit: http://setosa.io/ev/markov-chains/
’Twas brillig, and the slithy tove
Did gyre and gimble in the wabe
All mimsy were the borogoves,
And the mome raths outgrabe.
Beware the Jabberwock, my son!
The jaws that bite, the claws that
catch!
Markov Model – to generate text
Metrics
4 Copyright © 2022, Oracle and/or its affiliates
Measuring our Application – Metrics are Important
• We want to know how ”good” our app is
• How much resources it is using
Let’s Look at the Code
Copyright © 2022, Oracle and/or its affiliates
5
Native Executables in Containers
6 Copyright © 2022, Oracle and/or its affiliates
The frumious Bandersnatch!
Native Executables in Containers
7 Copyright © 2022, Oracle and/or its affiliates
Faster starting, smaller footprint
Ahead ofTime Compilation,AOT
But What is GraalVM Native Image?
Copyright © 2022, Oracle and/or its affiliates
8
JIT
$ java –cp
AOT
$ native-image
Maven / Gradle
Spring Native
9 Copyright © 2022, Oracle and/or its affiliates
Make Spring Boot just work with Native Image
• Provides tooling to make Spring Boot Apps just work with Native Image
• Part of Spring Boot 3
Let’s Look at the Code - Again
Copyright © 2022, Oracle and/or its affiliates
10
Recap
Copyright © 2022, Oracle and/or its affiliates
11
• Built a Java App
• Containerised it (Easy)
• Built a Native App & Containerised
• Native Starts Fast
• Small containers with little in
Deploying
12 Copyright © 2022, Oracle and/or its affiliates
Container Registry -> OKE
Java App
Native App
Container
Registry
OKE
Oracle K8s
StressTesting our Apps
13 Copyright © 2022, Oracle and/or its affiliates
Keeping it Fair
• Set the memory
• Fix in deployment Desc.
• JDK : 256 MB
• Native : 128 MB
• Keep the cores fixed
• Using : hey
Let’s Deploy &Test
Copyright © 2022, Oracle and/or its affiliates
14
JavaThrough the Looking Glass
15 Copyright © 2022, Oracle and/or its affiliates
Great Performance for the Cloud
Better Throughput : Native,
YMMV
Half the memory : Native
JavaThrough the Looking Glass
16 Copyright © 2022, Oracle and/or its affiliates
• This is just one example
• Low Foot-print? Native Image
• Long Running?GraalVM EE JVM
• GCs: Epsilon; Serial; G1;
• Through-put? Native Image + G1 + PGO
• Static linking (libmusl) / Mostly Static
• Supported by:
• Spring Native
• Micronaut
• Helidon
• Quarkus
Thank you!
Copyright © 2022, Oracle and/or its affiliates
17

CNCF Live Webinar: Low Footprint Java Containers with GraalVM

  • 1.
    GraalVM Native Image- Low Footprint Java in the Cloud JavaThrough the Looking Glass Kris Foster Principal Product Manager, GraalVM
  • 2.
    What is it? •Java Runtime (JDK11, JDK17) • New Fast & Efficient JIT Compiler • Applications => Native Executables • Multi-Language • Enterprise / Community Why should I care? • Java Runtime - Improved performance • Applications => Native Executables • Fast start-up, low footprint “The best way to explain it is to do it.” GraalVM Copyright © 2022, Oracle and/or its affiliates 2 What is it and why should I care?
  • 3.
    Java Apps inContainers 3 Copyright © 2022, Oracle and/or its affiliates Simple Spring Boot, Rest API Application Credit: http://setosa.io/ev/markov-chains/ ’Twas brillig, and the slithy tove Did gyre and gimble in the wabe All mimsy were the borogoves, And the mome raths outgrabe. Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Markov Model – to generate text
  • 4.
    Metrics 4 Copyright ©2022, Oracle and/or its affiliates Measuring our Application – Metrics are Important • We want to know how ”good” our app is • How much resources it is using
  • 5.
    Let’s Look atthe Code Copyright © 2022, Oracle and/or its affiliates 5
  • 6.
    Native Executables inContainers 6 Copyright © 2022, Oracle and/or its affiliates The frumious Bandersnatch!
  • 7.
    Native Executables inContainers 7 Copyright © 2022, Oracle and/or its affiliates Faster starting, smaller footprint
  • 8.
    Ahead ofTime Compilation,AOT ButWhat is GraalVM Native Image? Copyright © 2022, Oracle and/or its affiliates 8 JIT $ java –cp AOT $ native-image Maven / Gradle
  • 9.
    Spring Native 9 Copyright© 2022, Oracle and/or its affiliates Make Spring Boot just work with Native Image • Provides tooling to make Spring Boot Apps just work with Native Image • Part of Spring Boot 3
  • 10.
    Let’s Look atthe Code - Again Copyright © 2022, Oracle and/or its affiliates 10
  • 11.
    Recap Copyright © 2022,Oracle and/or its affiliates 11 • Built a Java App • Containerised it (Easy) • Built a Native App & Containerised • Native Starts Fast • Small containers with little in
  • 12.
    Deploying 12 Copyright ©2022, Oracle and/or its affiliates Container Registry -> OKE Java App Native App Container Registry OKE Oracle K8s
  • 13.
    StressTesting our Apps 13Copyright © 2022, Oracle and/or its affiliates Keeping it Fair • Set the memory • Fix in deployment Desc. • JDK : 256 MB • Native : 128 MB • Keep the cores fixed • Using : hey
  • 14.
    Let’s Deploy &Test Copyright© 2022, Oracle and/or its affiliates 14
  • 15.
    JavaThrough the LookingGlass 15 Copyright © 2022, Oracle and/or its affiliates Great Performance for the Cloud Better Throughput : Native, YMMV Half the memory : Native
  • 16.
    JavaThrough the LookingGlass 16 Copyright © 2022, Oracle and/or its affiliates • This is just one example • Low Foot-print? Native Image • Long Running?GraalVM EE JVM • GCs: Epsilon; Serial; G1; • Through-put? Native Image + G1 + PGO • Static linking (libmusl) / Mostly Static • Supported by: • Spring Native • Micronaut • Helidon • Quarkus
  • 17.
    Thank you! Copyright ©2022, Oracle and/or its affiliates 17