Containers for Java: Optimizing your applications —
Mofe Salami Developer Advocate
Containers for Java: Optimizing your applications Mofe Salami - - PowerPoint PPT Presentation
Containers for Java: Optimizing your applications Mofe Salami Developer Advocate Containers are great! App 1 App 2 App 3 Bins/Libs Bins/Libs Bins/Libs App 1 App 2 App 3 Guest OS Guest OS Guest OS Bins/Libs Bins/Libs Bins/Libs
Containers for Java: Optimizing your applications —
Mofe Salami Developer Advocate
Containers are great!
Physical Server Host Operating System Container Engine Bins/Libs Bins/Libs Bins/Libs App 1 App 2 App 3 Physical Server Host Operating System Hypervisor Guest OS Guest OS Guest OS Bins/Libs Bins/Libs Bins/Libs App 1 App 2 App 3
2
Java and containers, not so great
Java is nice but:
3
How can we address these issues?
Takeaways:
4
What this talk will not cover
5
Important, but not in scope:
6
Defining “application size”
7
Application size = Linux distribution + JVM + Application Code
Choosing the “right” JDK distribution
8
Points for consideration:
Read more:
Life Beyond Java 8 – Trisha Gee Panel: Java Is Still Free?
Oracle OpenJDK Build Release date Free updates superseded / ended (by Oracle) 8 (LTS) March 2014 At least through January 2020 (Personal desktop use) Commercial use ended in January 2019 9 Sept 2017 Superseded by Oracle OpenJDK build 10 10 March 2018 Superseded by Oracle OpenJDK build 11 in Sept 2018 11 (LTS) Sept 2018 To be superseded by Oracle OpenJDK build 12 in March 2019 (may be extended) 12 March 2019 To be superseded by Oracle OpenJDK build 13 13 Sept 2019 To be superseded by Oracle OpenJDK build 14
Choosing AdoptOpenJDK
9
Adopt OpenJDK Build Release date Update/Support period 8 (LTS) March 2014 At least September 2023 9 Sept 2017
March 2018
Sept 2018 At least September 2022
Choosing the “right” Linux distribution
10
docker pull adoptopenjdk/${VERSION}:${VARIANT}
Building the application
11
Simple Spring Boot Application Dockerfile
Building the application
12
docker build -t java-containers:adoptopenjdk-${VERSION}:${VARIANT} Dockerfile
Demo #1
13
docker run -p 8080:8080 --rm java-containers:adoptopenjdk-8-alpine-slim
Go to: localhost:8080/ping
14
JVM Start-up times
15
Total start-up time = JVM start-up time + application start-up time
Let’s experiment with:
Class Data Sharing (CDS)
16
Generate cache with:
Use with:
Classes from system jar file Private internal representation Dump to shared archive file
Benchmarking our application
17
Benchmark Results: CDS (Off vs. On)
18
Application Class Data Sharing (AppCDS)
19
Steps to use:
AppCDS: Generating shared cache file
20
AppCDS: Run application with AppCDS cache
21
Benchmark Results: CDS vs AppCDS
22
Ahead-of-time Compilation (AOT)
23
Steps to use:
AOT: Generating shared cache file
24
AOT: Run application with CDS + AppCDS + AOT
25
Benchmark Results: CDS vs CDS + AppCDS + AOT
26
Things to note
27
But wait… this is also a container talk…
28
But wait… this is also a container talk…
29
docker build -t java-container-opt:adoptopenjdk-11-alpine-slim .
30
An alternative JVM: OpenJ9
31
Stephen Hellberg – Open J9: Compelling Java for Cloud Workloads
OpenJ9: Putting it to the test (AdoptOpenJDK 11)
32
OpenJ9: Putting it to the test (AdoptOpenJDK 8)
33
They have images for it too!
34
Demo #2
35
AdoptOpenJDK 11 (CDS, AppCDs, AOT) Vs. AdoptOpenJDK 8 OpenJ9 (CDS, AOT)
Honorable mention 1: Graal and Subtrate VM
36
Duncan McGregor - Graal: Not Just a New JIT for the JVM
Honorable mention 2: Using modules & jLink
37
Workshop: https://github.com/IBMCodeLondon/java-containers101 Our London Meetup: https://www.meetup.com/IBM-Code-London
38
39