Slide 1

Slide 1 text

A year with JDK 11 in production Winter Premiere Edition! ags @ SnowOne 2020
 2020-02-29T15:00+07:00

Slide 2

Slide 2 text

andrzej grzesik Principal Engineer @ twitter://ags313 ags@revolut.com andrzejgrzesik.info

Slide 3

Slide 3 text

about:me

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

my opinions are my own

Slide 6

Slide 6 text

questions about the talk? just ask!

Slide 7

Slide 7 text

questions about ? talk to me after!

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Which Java are you on? Java 11

Slide 11

Slide 11 text

Which Java are you on? Java 11

Slide 12

Slide 12 text

Which Java are you on? Java 11

Slide 13

Slide 13 text

Which Java are you on? Java 11

Slide 14

Slide 14 text

Which Java are you on? Java 11

Slide 15

Slide 15 text

Джава upgrade

Slide 16

Slide 16 text

Джава upgrade in context

Slide 17

Slide 17 text

17 About Revolut Launched in July 2015 20+ offices around the world 2200+ employees 10M+ retail and 340K+ business users Total investment to date: $836M Check the actual number of retail customers here. Check the actual number of business customers here. Check the number of employees in the upper right corner. Total value of investment according to: https://www.bloomberg.com/news/articles/2020-02-25/revolut-valued-at-5-5-billion-in-fintech-s-latest-funding-round

Slide 18

Slide 18 text

Deployment …

Slide 19

Slide 19 text

Why upgrade?

Slide 20

Slide 20 text

Why upgrade? Get shIT done Move fast, keep things working Would have to upgrade anyway Want the the features and fixes

Slide 21

Slide 21 text

Why upgrade? Get shIT done Move fast, keep things working Would have to upgrade anyway Want the the features and fixes

Slide 22

Slide 22 text

Why upgrade? Get shIT done Move fast, keep things working Would have to upgrade anyway Want the the features and fixes

Slide 23

Slide 23 text

Why upgrade? Get shIT done Move fast, keep things working Would have to upgrade anyway Want new features and fixes

Slide 24

Slide 24 text

JSON is not your friend

Slide 25

Slide 25 text

java.lang.String Up to Java 8 
 From Java 9

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Upgrade and Ops automationn Developers take care of many infrastructure tasks 
 
 DevOps work on specialised projects

Slide 28

Slide 28 text

Джава 11 upgrade from jdk8u212-b03 to 11

Slide 29

Slide 29 text

Джава 11 upgrade from jdk8u212-b03 to 11, all apps

Slide 30

Slide 30 text

Why not… • 9 and 10 no longer maintained, no support (backports) • 12 wasn’t available

Slide 31

Slide 31 text

Why not Oracle JDK • Can’t build our own images • Can’t redistribute (this definition is broad) • Requires a license

Slide 32

Slide 32 text

Java - release cadence reminder • New release every 6 months • 3 builds for each major version • LTS (11 + n*6) edition get fixes for a longer period

Slide 33

Slide 33 text

Java - release cadence reminder

Slide 34

Slide 34 text

Java 11 Compiles on 11 Runs on 11 Compiles on 8 Runs on 11

Slide 35

Slide 35 text

Java 11 everywhere runtime AND toolchain

Slide 36

Slide 36 text

Using Java 11 And not full java 11 toolchain

Slide 37

Slide 37 text

I’ve got I’m holding you back! Cassandra <4.0 Grails <4.0.0 Hadoop <3.3.0 Kafka <2.1.0 Spring-boot <2.0 Thrift <0.13.0 … https://issues.apache.org/jira/browse/HADOOP-15338 http://cassandra.apache.org/doc/latest/new/java11.html https://github.com/apache/thrift/blob/master/LANGUAGES.md https://issues.apache.org/jira/browse/KAFKA-7264

Slide 38

Slide 38 text

Build tools

Slide 39

Slide 39 text

jdeps Shows module dependencies (including internal API usage)
 jdeps --jdk-internals --classpath theWorld.jar app.jar Gradle:
 https://github.com/kordamp/jdeps-gradle-plugin • Maven: maven-jdeps-plugin
 https://maven.apache.org/plugins/maven-jdeps-plugin/index.html

Slide 40

Slide 40 text

jdeprscan 
 Scans for usage of deprecated APIs
 jdeprscan --release 11 --list --for-removal --classpath theWorld.jar app.jar • Gradle: jdeprscan-gradle-plugin
 https://github.com/kordamp/jdeprscan-gradle-plugin • Maven: maven-jdeprscan-plugin 
 (https://maven.apache.org/plugins/maven-jdeprscan-plugin/index.html)

Slide 41

Slide 41 text

Maven

Slide 42

Slide 42 text

Maven …

Slide 43

Slide 43 text

Maven …

Slide 44

Slide 44 text

Gradle

Slide 45

Slide 45 text

Gradle v5 and v6 are good

Slide 46

Slide 46 text

Mockito • Formally, supports JDK 11 since 2.20.1

Slide 47

Slide 47 text

jOOQ • Supports JDK 11 since 3.12.0 • We’re on 3.11.x

Slide 48

Slide 48 text

An awesome framework to manage migrations of your database Combined with testcontainers, great for isolated and repeatable tests https://flywaydb.org/

Slide 49

Slide 49 text

Flyway • Supports JDK 11 since 5.2.0 • Encountered issues, moved back to 4.2.0

Slide 50

Slide 50 text

Java EE JEP 320

Slide 51

Slide 51 text

Java EE JEP 320

Slide 52

Slide 52 text

Languages

Slide 53

Slide 53 text

• Groovy? Yes, for Spock (http://spockframework.org/) • Upgraded Groovy to 2.4.16

Slide 54

Slide 54 text

Kotlin Supports JDK 9-12 since 1.3.30

Slide 55

Slide 55 text

Scala We’re using 2.12.7, just switched versions

Slide 56

Slide 56 text

Scala https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html

Slide 57

Slide 57 text

Testing with Postgres

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

Solution

Slide 61

Slide 61 text

Solution Bonus: Ask Sergey about Test Containers!

Slide 62

Slide 62 text

Dependencies

Slide 63

Slide 63 text

A B C depends on depends on

Slide 64

Slide 64 text

App Alpha Commons depends on depends on

Slide 65

Slide 65 text

App Alpha Commons depends on depends on Compile using 11

Slide 66

Slide 66 text

App Alpha Commons depends on depends on Compile using 11 Test using 11

Slide 67

Slide 67 text

App Alpha Commons depends on depends on Compile using 11 Test using 11 Run using 11

Slide 68

Slide 68 text

App Alpha Commons depends on depends on Compile using 11 Test using 11 Run using 11 Compile using 11

Slide 69

Slide 69 text

BouncyCastle • In JDK 8, it was common to install bouncycastle.jar into jre/lib/ext • This does not exist in JDK 9+ echo \ security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider \ 
 >> ${JAVA_HOME}/lib/security/java.security https://docs.oracle.com/javase/10/security/howtoimplaprovider.htm#JSSEC-GUID-FB9C6DB2-DE9A-4EFE-89B4-C2C168C5982D

Slide 70

Slide 70 text

VM options

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

java 
 -Xlog:gc*,gc+ref=debug,gc+phases=debug,gc+age=debug,safepoint:file=gc.log 
 -jar jar.binks java 
 -verbose:gc
 -Xloggc:my_very_own_gc-%t.log
 -XX:+PrintGC 
 -XX:+PrintGCApplicationStoppedTime 
 -XX:+PrintGCCause 
 -XX:+PrintGCDateStamps 
 -XX:+PrintGCDetails 
 -XX:+PrintReferenceGC 
 -XX:+PrintTenuringDistribution becomes

Slide 73

Slide 73 text

jaCoLine.dev

Slide 74

Slide 74 text

jaCoLine.dev

Slide 75

Slide 75 text

-XX changes

Slide 76

Slide 76 text

JDK 9+ java.util.zip.ZipFile The new java.util.zip.ZipFile implementation does NOT use mmap to map ZIP file central directory into memory anymore. 
 -Dsun.zip.disableMemoryMapping property is gone. https://bugs.openjdk.java.net/browse/JDK-8175192

Slide 77

Slide 77 text

Time precision

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

Nanotrusting the Nanotime https://shipilev.net/blog/2014/nanotrusting-nanotime/

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

Recommendation

Slide 85

Slide 85 text

DateTimeFormatter bug

Slide 86

Slide 86 text

No content

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

Compiler bugs

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

Turns out to be a duplicate of:

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

No content

Slide 95

Slide 95 text

Life with G1 as default G1@JDK11 is different than G1@JDK8!

Slide 96

Slide 96 text

Life with G1 as default G1: JDK 11 is different than JDK8! Bonus: Ask Oleg about G1 in JDK13

Slide 97

Slide 97 text

Life with G1 by default

Slide 98

Slide 98 text

Life with G1 by default • In JDK 11, full GCs are multi-threaded (since JDK 10, JEP-307) • No magic required to run human-perception pauseless • Kept increasing heap sizes, and observed no issues

Slide 99

Slide 99 text

Life with G1 by default • Less problems requiring gc logs • Faster OOM failures

Slide 100

Slide 100 text

No content

Slide 101

Slide 101 text

Memory appetite After moving to JDK 11, some containers died on us.

Slide 102

Slide 102 text

Changes to containers Let’s “live deploy” to Oracle Cloud and check!

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

Our finding • RSS of a Java 11 process would be higher than of Java 8. • For a fixed container size, we needed to decrease -Xmx and -Xms • Faster OOMs

Slide 105

Slide 105 text

Language features adoption

Slide 106

Slide 106 text

adoption of var, project S count 40000 53w 6d

Slide 107

Slide 107 text

adoption of var, project S count 40000 53w 6d

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

_

Slide 110

Slide 110 text

No content

Slide 111

Slide 111 text

Java Flight Record && Mission Control • Free && open source
 https://github.com/openjdk/jmc

Slide 112

Slide 112 text

What is next?

Slide 113

Slide 113 text

q: what is next? Java 13 has a lot of improvements in G1 space… … and no support anymore

Slide 114

Slide 114 text

q: what is next? Java 14 has features amazing for observability 
 (JEP-349, JFR event streaming, https://openjdk.java.net/jeps/349)
 
 However…
 Gradle does not support Java 14 yet (https://docs.gradle.org/current/ userguide/compatibility.html, https://github.com/gradle/gradle/issues/10248)

Slide 115

Slide 115 text

q: what is next? We plan to try , especially with Native Image.

Slide 116

Slide 116 text

How should you go about it?

Slide 117

Slide 117 text

Спаси ́ бо

Slide 118

Slide 118 text

Slides? 
 ags@revolut.com

Slide 119

Slide 119 text

Question time Slides? Email ags@revolut.com

Slide 120

Slide 120 text

q: THE_PERFORMANCE

Slide 121

Slide 121 text

Java - release cadence reminder • New release every 6 months • 3 builds for each major version • LTS (11 + n*6) edition get fixes for a longer period

Slide 122

Slide 122 text

Java - release cadence reminder

Slide 123

Slide 123 text

q: application CDS? not using

Slide 124

Slide 124 text

q: what about modules? In short, not yet.
 We are on a monolith -> modules journey

Slide 125

Slide 125 text

q: benefits from byte[] Strings? Yes, immediately taken over by increased traffic

Slide 126

Slide 126 text

q: which JDK We have adopted OpenJDK

Slide 127

Slide 127 text

We’. hiring! (and help with relocation - check out revolut.com/careers)

Slide 128

Slide 128 text

Resources Hand icon: http://icon-library.com/icon/raised-hand-icon-21.html Margaret Atwood quote: https://www.facebook.com/theweekuk/photos/a.282293375144981/3574042412636711/? type=3&theater Get IT done: https://community.fintechtalk.co.uk/t/whod-work-in-a-place-like-this/226 Java release graph: https://dzone.com/articles/thinking-of-moving-to-jdk-9-next-year-think-again Java 9 graphic: https://jcp.org/en/press/news/JCP_JavaOne2017 I want you: https://imgflip.com/memegenerator/23648483/I-WANT-YOU Hold my beverage: https://imgflip.com/memegenerator/96314734/Hold-my-beer Turn picture: https://www.dailymail.co.uk/femail/article-7227619/Drivers-left-baffled-road-marking-says-turn-LEFT-RIGHT.html Dog meme: https://imgflip.com/memegenerator/I-Have-No-Idea-What-I-Am-Doing-Dog Star Trek meme: https://memeshappen.com/meme/capt-kirk/what-is-the-meaning-25449/3