SlideShare a Scribd company logo
Copyright © 2019 Oracle and/or its affiliates.
JVMs in Containers
Best Practices
David Delabassée - @delabassee
DevRel
Java Platform Group - Oracle
November 2019
Copyright © 2019 Oracle and/or its affiliates.
@delabassee
Java Platform Group
Oracle
The following is intended to outline our general product direction. It is intended for information purposes
only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code,
or functionality, and should not be relied upon in making purchasing decisions. The development,
release, timing, and pricing of any features or functionality described for Oracle’s products may change
and remains at the sole discretion of Oracle Corporation.
Statements in this presentation relating to Oracle’s future plans, expectations, beliefs, intentions and
prospects are “forward-looking statements” and are subject to material risks and uncertainties. A detailed
discussion of these factors and other risks that affect our business is contained in Oracle’s Securities and
Exchange Commission (SEC) filings, including our most recent reports on Form 10-K and Form 10-Q
under the heading “Risk Factors.” These filings are available on the SEC’s website or on Oracle’s website
at http://www.oracle.com/investor. All information in this presentation is current as of September 2019
and Oracle undertakes no duty to update any statement in light of new information or future events.
Safe Harbor
Copyright © 2019 Oracle and/or its affiliates.
Copyright © 2019 Oracle and/or its affiliates.
Containers
• Package Software into Standardized Units
- Development
- Shipment
- Deployment
• Runtimes
- Docker, CRI-O, Podman, LXC, rkt, runC, systemd-nspawn, OpenVZ, etc.
Copyright © 2019 Oracle and/or its affiliates.
Container
Copyright © 2019 Oracle and/or its affiliates.
Container vs. VM
Infrastructure
Infrastructure
Host OS
Host OS
Hypervisor
Container Daemon
Guest OS A
Bin/libs
App #1
Bin/libs
App #1
Bin/libs
App #2
Guest OS B
Bin/libs
App #2
Java
Copyright © 2019 Oracle and/or its affiliates.
Tools
docker-maven-plugin
Jib + jib-maven-plugin
Testcontainers
…
Copyright © 2019 Oracle and/or its affiliates.
JVM Container Tooling
FaaS
Fn Project
OpenFaaS
OpenWhisk
…
Frameworks
Helidon
Quarkus
Micronaut
…
• JVM should behave as a good (Container) citizen
• “Improved latency”
Copyright © 2019 Oracle and/or its affiliates.
JVM in Containers
Hello Container
Demo
Copyright © 2019 Oracle and/or its affiliates.
Latency
Copyright © 2019 Oracle and/or its affiliates.
Copyright © 2019 Oracle and/or its affiliates.
Latency
Container Start-Up
• 3 “core” layers
- Java application and its dependencies
- Java Runtime
- Operating System
• ⇨ Reduce layers size
Copyright © 2019 Oracle and/or its affiliates.
Stack of Layers
• Dependencies
• Leverage Container cache layer mechanism
• Anything that is (relatively) static in its own layer
• Fat JAR
• CDS Shared Archive
Copyright © 2019 Oracle and/or its affiliates.
Stack of Layers
Copyright © 2019 Oracle and/or its affiliates.
Java Runtime Image
Modules jlink flags MB
JDK Whole JDK! 316 100%
Runtime image All (explicit) --add-modules $(java --list-modules) 178 56% 100%
Custom runtime image Required modules only --add-modules $(jdeps --print-module-deps …) 50 16% 28%
… --no-header-files --no-man-pages
--strip-java-debug-attributes 44 14% 25%
… --compress=1 37 12% 21%
… --compress=2 34 11% 19%
316 MB 178 MB 50 MB 34 MB
Serverless Java function (Fn) - openjdk:13
• musl
Lightweight, fast, simple, free, C standard library implementation
https://www.musl-libc.org
• Alpine
Security-oriented, lightweight Linux distro with 4MB base image
https://www.alpinelinux.org
• Project Portola
Run the JVM on musl
https://openjdk.java.net/projects/portola/
Copyright © 2019 Oracle and/or its affiliates.
Operating System
Copyright © 2019 Oracle and/or its affiliates.
Copyright © 2019 Oracle and/or its affiliates.
Java Runtime Image
Minecraft server
java.base, java.compiler, java.desktop, java.management, java.naming,
java.rmi, java.scripting, java.sql, jdk.sctp, jdk.unsupported, jdk.zipfs
openjdk:13 - 12 modules 88 MB
--strip-debug --strip-java-debug-attributes -14 MB
--compress=1 -18 MB
--compress=2 -31 MB
--no-header-file --no-man-pages 0 MB (*)
openjdk-11-jdk (debian:buster) - all modules 554 MB (!!)
12 modules 469 MB
--strip-native-debug-symbols (new)
Copyright © 2019 Oracle and/or its affiliates.
Latency
Application Start-Up
0
10
20
30
40
50
60
70
80
90
8 9 10 11 12 13
time(ms)
Hello World
Copyright © 2019 Oracle and/or its affiliates.
Startup Time
• Bootstrap regressions in JDK 9 fixed! Keep on fixing!
• +120 startup-related enhancements in JDK 10 through JDK 13!
• Reduce memory footprint between multiple JVMs by sharing
common class metadata
• Improve startup time
• How?
- Loads classes from JAR file into a private internal representation
- Dumps it to a shared archive
- When JVMs (re)starts, the archive is memory-mapped to allow sharing of
R/O JVM metadata for these classes among multiple JVMs
Copyright © 2019 Oracle and/or its affiliates.
Class Data Sharing
CDS
Demo
Copyright © 2019 Oracle and/or its affiliates.
Copyright © 2019 Oracle and/or its affiliates.
Application CDS
Copyright © 2019 Oracle and/or its affiliates.
Application CDS
jdk-08-u202-b08-hotspot
jruby -e 1
real 0m1.601s
user 0m4.434s
sys 0m0.234s
jruby --dev -e 1
real 0m1.216s
user 0m1.646s
sys 0m0.162s
jruby --disable-gems --dev -e 1
real 0m0.853s
user 0m1.030s
sys 0m0.113s
jdk-13.jdk
… -J-XX:SharedArchiveFile=jruby.jsa
real 0m1.491s
user 0m3.378s
sys 0m0.220s
… -J-XX:SharedArchiveFile=jruby.jsa
real 0m1.089s
user 0m1.644s
sys 0m0.133s
… -J-XX:SharedArchiveFile=jruby.jsa
real 0m0.717s
user 0m0.944s
sys 0m0.110s
• Java 5 - Limited to system classes and serial GC
• Java 9 - Application CDS and other GCs (commercial feature + JEP 250)
• Java 10 - Application CDS (JEP 310)
• Java 12 - Default CDS Archives (JEP 341)
• Java 13 - Dynamic CDS Archives (JEP 350)
- Dynamic archiving of classes at the end of application execution
-XX:ArchiveClassesAtExit=my-app-cds.jsa
Copyright © 2019 Oracle and/or its affiliates.
Class Data Sharing
• High Performance Universal Virtual Machine
• Polyglot
• …
• Native Image
- Reduced startup time
- Improved foot-print
- Reduced image size
Copyright © 2019 Oracle and/or its affiliates.
GraalVM
https://www.graalvm.org
• Java 8 & 11
• Not supported
- InvokeDynamic and Method Handles, Dynamic Class Un/Loading, Finalizers, Security
Manager
- JVMTI, JMX, other native VM interfaces
• Mostly supported, or supported via configuration
- Reflections, Dynamic Proxy, JNI, Unsafe Memory Access, Static Initializers, References
Copyright © 2019 Oracle and/or its affiliates.
GraalVM limitations
https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md
Copyright © 2019 Oracle and/or its affiliates.
Container
JVM should behave as a good citizen
JDK-8179498 attach should be relative to /proc/pid/root and namespace
aware as jcmd, jstack, ... fail to attach (10)
JDK-8146115 Improve Docker container detection & resource config usage (10)
JDK-8193710 jcmd –l & jps do not list Java processes running in containers (11)
JDK-8203357 Container Metrics (11)
JDK-8186248 More flexibility in selecting Heap % of available RAM (8u144)
JDK-8203359 JFR jdk.CPUInformation event reports incorrect information when
running in Docker container (open)
JDK-8228428 OperatingSystemMXBean should be made container aware (open 14)
…
Copyright © 2019 Oracle and/or its affiliates.
Container Awareness
• The JVM tunes itself based on the system it runs on
• Behavior-Based Tuning dynamically optimizes the sizes of the heap
to meet an expected behavior
- Maximum Pause-time (-XX:MaxGCPauseMillis)
- Or Application Throughput (-XX:GCTimeRatio)
• Sets defaults for the GC, heap size, and runtime compiler
Copyright © 2019 Oracle and/or its affiliates.
Ergonomics
https://docs.oracle.com/en/java/javase/13/gctuning/ergonomics.html
Ergonomics
Demo
Copyright © 2019 Oracle and/or its affiliates.
Copyright © 2019 Oracle and/or its affiliates.
Wrap-Up
• Reduced “latency”
- Container Startup
- Application Startup
• JVM behaves as a good (Container) citizen
Copyright © 2019 Oracle and/or its affiliates.
JVMs in Containers
• Use the latest Java version and never java:latest !!!
• Only rely on actively-supported versions!
• Use a JRE Java runtime image instead of a JDK
• Move startup costs to the build phase
• It’s “containers as usual”
- Docker-bench-security, Snyk, Clair, Anchore, etc.
- Small(er) is better
- Reduce the potential attack surface
- Multistage build, etc.
Copyright © 2019 Oracle and/or its affiliates.
JVMs in Containers
Copyright © 2019 Oracle and/or its affiliates.
Choose your base image wisely
Copyright © 2019 Oracle and/or its affiliates.
Choose your base image wisely
and secure it!
ありがとうございます
Copyright © 2019 Oracle and/or its affiliates.
DevRel
Java Platform Group - Oracle
October 2019
David Delabassée - @delabassee

More Related Content

What's hot

What's hot (20)

MySQL User Camp: GTIDs
MySQL User Camp: GTIDsMySQL User Camp: GTIDs
MySQL User Camp: GTIDs
 
Java modules using project jigsaw@jdk 9
Java modules using project jigsaw@jdk 9Java modules using project jigsaw@jdk 9
Java modules using project jigsaw@jdk 9
 
Running your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudRunning your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the Cloud
 
20191119 Cloud Native Java : GraalVM
20191119 Cloud Native Java : GraalVM20191119 Cloud Native Java : GraalVM
20191119 Cloud Native Java : GraalVM
 
Cloud Consolidation with Oracle (RAC) - How much is too much?
Cloud Consolidation with Oracle (RAC) - How much is too much?Cloud Consolidation with Oracle (RAC) - How much is too much?
Cloud Consolidation with Oracle (RAC) - How much is too much?
 
The Kubernetes WebLogic revival (part 1)
The Kubernetes WebLogic revival (part 1)The Kubernetes WebLogic revival (part 1)
The Kubernetes WebLogic revival (part 1)
 
The Oracle RAC Family of Solutions - Presentation
The Oracle RAC Family of Solutions - PresentationThe Oracle RAC Family of Solutions - Presentation
The Oracle RAC Family of Solutions - Presentation
 
Troubleshooting Tools In JDK
Troubleshooting Tools In JDKTroubleshooting Tools In JDK
Troubleshooting Tools In JDK
 
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
 
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
 
Java Summit Chennai: JAX-RS 2.0
Java Summit Chennai: JAX-RS 2.0Java Summit Chennai: JAX-RS 2.0
Java Summit Chennai: JAX-RS 2.0
 
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
OSGi & Java EE in GlassFish @ Silicon Valley Code Camp 2010
 
Oracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion EditionOracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion Edition
 
How to Become a Winner in the JVM Performance-Tuning Battle
How to Become a Winner in the JVM Performance-Tuning BattleHow to Become a Winner in the JVM Performance-Tuning Battle
How to Become a Winner in the JVM Performance-Tuning Battle
 
Oracle RAC BP for Upgrade & More by Anil Nair and Markus Michalewicz
Oracle RAC BP for Upgrade & More by Anil Nair and Markus MichalewiczOracle RAC BP for Upgrade & More by Anil Nair and Markus Michalewicz
Oracle RAC BP for Upgrade & More by Anil Nair and Markus Michalewicz
 
Running your Java EE 6 applications in the Cloud @ Silicon Valley Code Camp 2010
Running your Java EE 6 applications in the Cloud @ Silicon Valley Code Camp 2010Running your Java EE 6 applications in the Cloud @ Silicon Valley Code Camp 2010
Running your Java EE 6 applications in the Cloud @ Silicon Valley Code Camp 2010
 
Aneez Hasan_Resume
Aneez Hasan_ResumeAneez Hasan_Resume
Aneez Hasan_Resume
 
Oracle Multitenant meets Oracle RAC - IOUG 2014 Version
Oracle Multitenant meets Oracle RAC - IOUG 2014 VersionOracle Multitenant meets Oracle RAC - IOUG 2014 Version
Oracle Multitenant meets Oracle RAC - IOUG 2014 Version
 
Oracle RAC 12c Best Practices with Appendices DOAG2013
Oracle RAC 12c Best Practices with Appendices DOAG2013Oracle RAC 12c Best Practices with Appendices DOAG2013
Oracle RAC 12c Best Practices with Appendices DOAG2013
 
JDK 9 Java Platform Module System
JDK 9 Java Platform Module SystemJDK 9 Java Platform Module System
JDK 9 Java Platform Module System
 

Similar to JVMs in Containers - Best Practices

Similar to JVMs in Containers - Best Practices (20)

JVMs in Containers
JVMs in ContainersJVMs in Containers
JVMs in Containers
 
Serverless Java - Challenges and Triumphs
Serverless Java - Challenges and TriumphsServerless Java - Challenges and Triumphs
Serverless Java - Challenges and Triumphs
 
Java Cloud and Container Ready
Java Cloud and Container ReadyJava Cloud and Container Ready
Java Cloud and Container Ready
 
JDK 10 Java Module System
JDK 10 Java Module SystemJDK 10 Java Module System
JDK 10 Java Module System
 
JDK 8 and JDK 8 Updates in OpenJDK
JDK 8 and JDK 8 Updates in OpenJDKJDK 8 and JDK 8 Updates in OpenJDK
JDK 8 and JDK 8 Updates in OpenJDK
 
Java in a world of containers
Java in a world of containersJava in a world of containers
Java in a world of containers
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The Cloud
 
Developing Java EE Applications on IntelliJ IDEA with Oracle WebLogic 12c
Developing Java EE Applications on IntelliJ IDEA with Oracle WebLogic 12cDeveloping Java EE Applications on IntelliJ IDEA with Oracle WebLogic 12c
Developing Java EE Applications on IntelliJ IDEA with Oracle WebLogic 12c
 
Java 40 versions_sgp
Java 40 versions_sgpJava 40 versions_sgp
Java 40 versions_sgp
 
Accelerating Spark Genome Sequencing in Cloud—A Data Driven Approach, Case St...
Accelerating Spark Genome Sequencing in Cloud—A Data Driven Approach, Case St...Accelerating Spark Genome Sequencing in Cloud—A Data Driven Approach, Case St...
Accelerating Spark Genome Sequencing in Cloud—A Data Driven Approach, Case St...
 
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVMDiagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
 
Java is Container Ready - Vaibhav - Container Conference 2018
Java is Container Ready - Vaibhav - Container Conference 2018Java is Container Ready - Vaibhav - Container Conference 2018
Java is Container Ready - Vaibhav - Container Conference 2018
 
SemeruRuntimesUnderTheCover .pptx
SemeruRuntimesUnderTheCover .pptxSemeruRuntimesUnderTheCover .pptx
SemeruRuntimesUnderTheCover .pptx
 
Java @ Cloud - Setor Público SP
Java @ Cloud - Setor Público SPJava @ Cloud - Setor Público SP
Java @ Cloud - Setor Público SP
 
Splunking the JVM
Splunking the JVMSplunking the JVM
Splunking the JVM
 
Node.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development TechniquesNode.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development Techniques
 
JFokus 2011 - Running your Java EE 6 apps in the Cloud
JFokus 2011 - Running your Java EE 6 apps in the CloudJFokus 2011 - Running your Java EE 6 apps in the Cloud
JFokus 2011 - Running your Java EE 6 apps in the Cloud
 
WebLogic 12c - OMF Canberra June 2014
WebLogic 12c - OMF Canberra June 2014WebLogic 12c - OMF Canberra June 2014
WebLogic 12c - OMF Canberra June 2014
 
Running your Java EE 6 Applications in the Cloud
Running your Java EE 6 Applications in the CloudRunning your Java EE 6 Applications in the Cloud
Running your Java EE 6 Applications in the Cloud
 

More from David Delabassee

More from David Delabassee (20)

Randstad Docker meetup - Serverless
Randstad Docker meetup - ServerlessRandstad Docker meetup - Serverless
Randstad Docker meetup - Serverless
 
Java Serverless in Action - Voxxed Banff
Java Serverless in Action - Voxxed BanffJava Serverless in Action - Voxxed Banff
Java Serverless in Action - Voxxed Banff
 
Serverless Kotlin
Serverless KotlinServerless Kotlin
Serverless Kotlin
 
REST in an Async World
REST in an Async WorldREST in an Async World
REST in an Async World
 
JAX-RS 2.1 Reloaded
JAX-RS 2.1 ReloadedJAX-RS 2.1 Reloaded
JAX-RS 2.1 Reloaded
 
Java EE 8 - February 2017 update
Java EE 8 - February 2017 updateJava EE 8 - February 2017 update
Java EE 8 - February 2017 update
 
Java EE Next
Java EE NextJava EE Next
Java EE Next
 
Java EE Next - BeJUG JavaOne Afterglow 2016
Java EE Next - BeJUG JavaOne Afterglow 2016Java EE Next - BeJUG JavaOne Afterglow 2016
Java EE Next - BeJUG JavaOne Afterglow 2016
 
HTTP/2 comes to Java
HTTP/2 comes to JavaHTTP/2 comes to Java
HTTP/2 comes to Java
 
Java EE 8 - Work in progress
Java EE 8 - Work in progressJava EE 8 - Work in progress
Java EE 8 - Work in progress
 
HTTP/2 comes to Java (Dec. 2015 version)
HTTP/2 comes to Java (Dec. 2015 version)HTTP/2 comes to Java (Dec. 2015 version)
HTTP/2 comes to Java (Dec. 2015 version)
 
EJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and StrategyEJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and Strategy
 
HTTP/2 Comes to Java
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to Java
 
Java EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web frontJava EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web front
 
HTTP/2 Comes to Java
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to Java
 
What's coming in Java EE 8
What's coming in Java EE 8What's coming in Java EE 8
What's coming in Java EE 8
 
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
 
MVC 1.0 / JSR 371
MVC 1.0 / JSR 371MVC 1.0 / JSR 371
MVC 1.0 / JSR 371
 
Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshot Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshot
 
Avatar 2.0
Avatar 2.0Avatar 2.0
Avatar 2.0
 

Recently uploaded

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 

Recently uploaded (20)

Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 

JVMs in Containers - Best Practices

  • 1. Copyright © 2019 Oracle and/or its affiliates. JVMs in Containers Best Practices David Delabassée - @delabassee DevRel Java Platform Group - Oracle November 2019
  • 2. Copyright © 2019 Oracle and/or its affiliates. @delabassee Java Platform Group Oracle
  • 3. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation. Statements in this presentation relating to Oracle’s future plans, expectations, beliefs, intentions and prospects are “forward-looking statements” and are subject to material risks and uncertainties. A detailed discussion of these factors and other risks that affect our business is contained in Oracle’s Securities and Exchange Commission (SEC) filings, including our most recent reports on Form 10-K and Form 10-Q under the heading “Risk Factors.” These filings are available on the SEC’s website or on Oracle’s website at http://www.oracle.com/investor. All information in this presentation is current as of September 2019 and Oracle undertakes no duty to update any statement in light of new information or future events. Safe Harbor Copyright © 2019 Oracle and/or its affiliates.
  • 4. Copyright © 2019 Oracle and/or its affiliates. Containers
  • 5. • Package Software into Standardized Units - Development - Shipment - Deployment • Runtimes - Docker, CRI-O, Podman, LXC, rkt, runC, systemd-nspawn, OpenVZ, etc. Copyright © 2019 Oracle and/or its affiliates. Container
  • 6. Copyright © 2019 Oracle and/or its affiliates. Container vs. VM Infrastructure Infrastructure Host OS Host OS Hypervisor Container Daemon Guest OS A Bin/libs App #1 Bin/libs App #1 Bin/libs App #2 Guest OS B Bin/libs App #2
  • 7. Java Copyright © 2019 Oracle and/or its affiliates.
  • 8. Tools docker-maven-plugin Jib + jib-maven-plugin Testcontainers … Copyright © 2019 Oracle and/or its affiliates. JVM Container Tooling FaaS Fn Project OpenFaaS OpenWhisk … Frameworks Helidon Quarkus Micronaut …
  • 9. • JVM should behave as a good (Container) citizen • “Improved latency” Copyright © 2019 Oracle and/or its affiliates. JVM in Containers
  • 10. Hello Container Demo Copyright © 2019 Oracle and/or its affiliates.
  • 11. Latency Copyright © 2019 Oracle and/or its affiliates.
  • 12. Copyright © 2019 Oracle and/or its affiliates. Latency Container Start-Up
  • 13. • 3 “core” layers - Java application and its dependencies - Java Runtime - Operating System • ⇨ Reduce layers size Copyright © 2019 Oracle and/or its affiliates. Stack of Layers
  • 14. • Dependencies • Leverage Container cache layer mechanism • Anything that is (relatively) static in its own layer • Fat JAR • CDS Shared Archive Copyright © 2019 Oracle and/or its affiliates. Stack of Layers
  • 15. Copyright © 2019 Oracle and/or its affiliates. Java Runtime Image Modules jlink flags MB JDK Whole JDK! 316 100% Runtime image All (explicit) --add-modules $(java --list-modules) 178 56% 100% Custom runtime image Required modules only --add-modules $(jdeps --print-module-deps …) 50 16% 28% … --no-header-files --no-man-pages --strip-java-debug-attributes 44 14% 25% … --compress=1 37 12% 21% … --compress=2 34 11% 19% 316 MB 178 MB 50 MB 34 MB Serverless Java function (Fn) - openjdk:13
  • 16. • musl Lightweight, fast, simple, free, C standard library implementation https://www.musl-libc.org • Alpine Security-oriented, lightweight Linux distro with 4MB base image https://www.alpinelinux.org • Project Portola Run the JVM on musl https://openjdk.java.net/projects/portola/ Copyright © 2019 Oracle and/or its affiliates. Operating System
  • 17. Copyright © 2019 Oracle and/or its affiliates.
  • 18. Copyright © 2019 Oracle and/or its affiliates. Java Runtime Image Minecraft server java.base, java.compiler, java.desktop, java.management, java.naming, java.rmi, java.scripting, java.sql, jdk.sctp, jdk.unsupported, jdk.zipfs openjdk:13 - 12 modules 88 MB --strip-debug --strip-java-debug-attributes -14 MB --compress=1 -18 MB --compress=2 -31 MB --no-header-file --no-man-pages 0 MB (*) openjdk-11-jdk (debian:buster) - all modules 554 MB (!!) 12 modules 469 MB --strip-native-debug-symbols (new)
  • 19. Copyright © 2019 Oracle and/or its affiliates. Latency Application Start-Up
  • 20. 0 10 20 30 40 50 60 70 80 90 8 9 10 11 12 13 time(ms) Hello World Copyright © 2019 Oracle and/or its affiliates. Startup Time • Bootstrap regressions in JDK 9 fixed! Keep on fixing! • +120 startup-related enhancements in JDK 10 through JDK 13!
  • 21. • Reduce memory footprint between multiple JVMs by sharing common class metadata • Improve startup time • How? - Loads classes from JAR file into a private internal representation - Dumps it to a shared archive - When JVMs (re)starts, the archive is memory-mapped to allow sharing of R/O JVM metadata for these classes among multiple JVMs Copyright © 2019 Oracle and/or its affiliates. Class Data Sharing
  • 22. CDS Demo Copyright © 2019 Oracle and/or its affiliates.
  • 23. Copyright © 2019 Oracle and/or its affiliates. Application CDS
  • 24. Copyright © 2019 Oracle and/or its affiliates. Application CDS jdk-08-u202-b08-hotspot jruby -e 1 real 0m1.601s user 0m4.434s sys 0m0.234s jruby --dev -e 1 real 0m1.216s user 0m1.646s sys 0m0.162s jruby --disable-gems --dev -e 1 real 0m0.853s user 0m1.030s sys 0m0.113s jdk-13.jdk … -J-XX:SharedArchiveFile=jruby.jsa real 0m1.491s user 0m3.378s sys 0m0.220s … -J-XX:SharedArchiveFile=jruby.jsa real 0m1.089s user 0m1.644s sys 0m0.133s … -J-XX:SharedArchiveFile=jruby.jsa real 0m0.717s user 0m0.944s sys 0m0.110s
  • 25. • Java 5 - Limited to system classes and serial GC • Java 9 - Application CDS and other GCs (commercial feature + JEP 250) • Java 10 - Application CDS (JEP 310) • Java 12 - Default CDS Archives (JEP 341) • Java 13 - Dynamic CDS Archives (JEP 350) - Dynamic archiving of classes at the end of application execution -XX:ArchiveClassesAtExit=my-app-cds.jsa Copyright © 2019 Oracle and/or its affiliates. Class Data Sharing
  • 26. • High Performance Universal Virtual Machine • Polyglot • … • Native Image - Reduced startup time - Improved foot-print - Reduced image size Copyright © 2019 Oracle and/or its affiliates. GraalVM https://www.graalvm.org
  • 27. • Java 8 & 11 • Not supported - InvokeDynamic and Method Handles, Dynamic Class Un/Loading, Finalizers, Security Manager - JVMTI, JMX, other native VM interfaces • Mostly supported, or supported via configuration - Reflections, Dynamic Proxy, JNI, Unsafe Memory Access, Static Initializers, References Copyright © 2019 Oracle and/or its affiliates. GraalVM limitations https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md
  • 28. Copyright © 2019 Oracle and/or its affiliates. Container JVM should behave as a good citizen
  • 29. JDK-8179498 attach should be relative to /proc/pid/root and namespace aware as jcmd, jstack, ... fail to attach (10) JDK-8146115 Improve Docker container detection & resource config usage (10) JDK-8193710 jcmd –l & jps do not list Java processes running in containers (11) JDK-8203357 Container Metrics (11) JDK-8186248 More flexibility in selecting Heap % of available RAM (8u144) JDK-8203359 JFR jdk.CPUInformation event reports incorrect information when running in Docker container (open) JDK-8228428 OperatingSystemMXBean should be made container aware (open 14) … Copyright © 2019 Oracle and/or its affiliates. Container Awareness
  • 30. • The JVM tunes itself based on the system it runs on • Behavior-Based Tuning dynamically optimizes the sizes of the heap to meet an expected behavior - Maximum Pause-time (-XX:MaxGCPauseMillis) - Or Application Throughput (-XX:GCTimeRatio) • Sets defaults for the GC, heap size, and runtime compiler Copyright © 2019 Oracle and/or its affiliates. Ergonomics https://docs.oracle.com/en/java/javase/13/gctuning/ergonomics.html
  • 31. Ergonomics Demo Copyright © 2019 Oracle and/or its affiliates.
  • 32. Copyright © 2019 Oracle and/or its affiliates. Wrap-Up
  • 33. • Reduced “latency” - Container Startup - Application Startup • JVM behaves as a good (Container) citizen Copyright © 2019 Oracle and/or its affiliates. JVMs in Containers
  • 34. • Use the latest Java version and never java:latest !!! • Only rely on actively-supported versions! • Use a JRE Java runtime image instead of a JDK • Move startup costs to the build phase • It’s “containers as usual” - Docker-bench-security, Snyk, Clair, Anchore, etc. - Small(er) is better - Reduce the potential attack surface - Multistage build, etc. Copyright © 2019 Oracle and/or its affiliates. JVMs in Containers
  • 35. Copyright © 2019 Oracle and/or its affiliates. Choose your base image wisely
  • 36. Copyright © 2019 Oracle and/or its affiliates. Choose your base image wisely and secure it!
  • 37. ありがとうございます Copyright © 2019 Oracle and/or its affiliates. DevRel Java Platform Group - Oracle October 2019 David Delabassée - @delabassee