S U P E R S O N I C . S U B A T O M I C . J A V A . S U P E R S O - - PowerPoint PPT Presentation

s u p e r s o n i c s u b a t o m i c j a v a s u p e r s
SMART_READER_LITE
LIVE PREVIEW

S U P E R S O N I C . S U B A T O M I C . J A V A . S U P E R S O - - PowerPoint PPT Presentation

S U P E R S O N I C . S U B A T O M I C . J A V A . S U P E R S O N I C . S U B A T O M I C . J A V A . @SanneGrinovero L O N G R U N N I N G S E R V E R , L O N G R U N N I N G S E R V E R , P E R F O R M A N C E P E R F O R M A N C E


slide-1
SLIDE 1

S U P E R S O N I C . S U B A T O M I C . J A V A . S U P E R S O N I C . S U B A T O M I C . J A V A . @SanneGrinovero

slide-2
SLIDE 2
slide-3
SLIDE 3

L O N G R U N N I N G S E R V E R , L O N G R U N N I N G S E R V E R , P E R F O R M A N C E P E R F O R M A N C E

slide-4
SLIDE 4

W H A T I F . . . C O N T I N U O U S W H A T I F . . . C O N T I N U O U S D E L I V E R Y D E L I V E R Y

slide-5
SLIDE 5

B L A C K F R I D A Y : O U R B L A C K F R I D A Y : O U R W O R S T N I G H T M A R E ? W O R S T N I G H T M A R E ?

slide-6
SLIDE 6
slide-7
SLIDE 7

W E H A V E A P R O B L E M ? W E H A V E A P R O B L E M ?

Long warmup times are no longer acceptable

slide-8
SLIDE 8

E N E M I E S O F S L O W E N E M I E S O F S L O W S T A R T U P S T A R T U P

Continuous Delivery

  • Elasticity, scale on cloud: trends, people, reality
slide-9
SLIDE 9

I ' M S A N N E G R I N O V E R O I ' M S A N N E G R I N O V E R O

Dutch, Italian, living in London. Red Hat, middleware engineering

  • R&D

Hibernate team lead

Quarkus, founding team member

Architect, Sr. Principal Software Engineer

Passionate about all OSS, Java & performance

slide-10
SLIDE 10

S U P E R S O N I C ? S U P E R S O N I C ?

FAST BOOT is now essential

  • How Quarkus achieves it
slide-11
SLIDE 11

S U B A T O M I C ? S U B A T O M I C ?

LOW MEMORY, high density

  • How Quarkus achieves it
slide-12
SLIDE 12

J A V A ? J A V A ?

Enable use of existing know-how

  • Leverage all great existing libraries
  • And yet enable strong innovation
slide-13
SLIDE 13

W H A T I S Q U A R K U S W H A T I S Q U A R K U S

slide-14
SLIDE 14

T O O L K I T T O O L K I T

and

F R A M E W O R K F R A M E W O R K

for writing Java applications

slide-15
SLIDE 15

L I G H T , C L O U D F R I E N D L Y , L I G H T , C L O U D F R I E N D L Y , D E S I G N E D F O R G R A A L V M D E S I G N E D F O R G R A A L V M

Helps overcome limitations of GraalVM

slide-16
SLIDE 16

L I G H T , C L O U D F R I E N D L Y , L I G H T , C L O U D F R I E N D L Y , D E S I G N E D F O R G R A A L V M D E S I G N E D F O R G R A A L V M

Helps overcome limitations of GraalVM Embrace these limitations, we love them!

slide-17
SLIDE 17

*.class QUARKUS

  • ptimized jar

native executable JVM

Maven/Gradle plugin

slide-18
SLIDE 18

E X T E N S I O N S E X T E N S I O N S

For each Java framework, a Quarkus extension Makes it compatible with GraalVM native-images And makes it much lighter to run on JVM

slide-19
SLIDE 19

L I B R A R I E S Y O U A L R E A D Y K N O W L I B R A R I E S Y O U A L R E A D Y K N O W

ECLIPSE VERT.X HIBERNATE RESTEASY APACHE CAMEL NETTY KUBERNETES JAEGER PROMETHEUS APACHE KAFKA INFINISPAN

slide-20
SLIDE 20

Unifies

I M P E R A T I V E I M P E R A T I V E

and R E A C T I V E

R E A C T I V E

@Inject SayService say; @GET @Produces(MediaType.TEXT_PLAIN) public String hello() { return say.hello(); } @Inject @Stream("kafka") Publisher<String> reactiveSay @GET @Produces(MediaType.SERVER_SEN public Publisher<String> stre return reactiveSay; }

slide-21
SLIDE 21

C O N T A I N E R F I R S T C O N T A I N E R F I R S T

slide-22
SLIDE 22

C O N T A I N E R F I R S T C O N T A I N E R F I R S T

Small size on disk Small container images 💿 ✓

slide-23
SLIDE 23

C O N T A I N E R F I R S T C O N T A I N E R F I R S T

Small size on disk Small container images Fast boot time Instant scale up 💿 ✓ 🚁 ✓

slide-24
SLIDE 24

C O N T A I N E R F I R S T C O N T A I N E R F I R S T

Small size on disk Small container images Fast boot time Instant scale up Low RSS1 memory

1) Resident Set Size

More containers with the same RAM 💿 ✓ 🚁 ✓ 🔭 ✓

slide-25
SLIDE 25

M E A S U R I N G M E M O R Y M E A S U R I N G M E M O R Y

= all actual RAM consumed by the process There's more than heap sizes! See also: RSS

$ ps -o pid,rss,command -p $(pgrep quarkus) PID RSS COMMAND 11229 12628 ./target/quarkus-hello java -XX:MaxRAM=50m -Xmx15m -Xss228k -jar app.jar

developers.redhat.com/blog/2017/04/04/openjdk- and-containers/

slide-26
SLIDE 26

M E M O R Y ( R S S ) M E M O R Y ( R S S )

Quarkus + GraalVM Quarkus + OpenJDK Best of traditio

slide-27
SLIDE 27

M E M O R Y ( R S S ) M E M O R Y ( R S S )

Quarkus + GraalVM Quarkus + OpenJDK Best of traditio

REST REST 13 MB 13 MB 74 MB 74 MB 140 M 140 M

slide-28
SLIDE 28

M E M O R Y ( R S S ) M E M O R Y ( R S S )

Quarkus + GraalVM Quarkus + OpenJDK Best of traditio

REST REST 13 MB 13 MB 74 MB 74 MB 140 M 140 M REST+JPA REST+JPA 35 MB 35 MB 130 MB 130 MB 218 M 218 M

slide-29
SLIDE 29

S T A R T U P T I M E S T A R T U P T I M E

Often frameworks use lazy initialization "started" reported too early

slide-30
SLIDE 30

S T A R T U P T I M E S T A R T U P T I M E

Often frameworks use lazy initialization "started" reported too early Measure time to first request

slide-31
SLIDE 31

T I M E T O F I R S T R E Q U E S T T I M E T O F I R S T R E Q U E S T

s + GraalVM 0.014 sec Quarkus + OpenJDK 0.75 sec Traditional Cloud-Native Stack 4.3 sec

slide-32
SLIDE 32

T I M E T O F I R S T R E Q U E S T T I M E T O F I R S T R E Q U E S T

s + GraalVM 0.014 sec Quarkus + OpenJDK 0.75 sec Traditional Cloud-Native Stack 4.3 sec

JPA & DB operations

s + GraalVM 0.055 sec Quarkus + OpenJDK 2.5 sec Traditional Cloud-Native Stack

slide-33
SLIDE 33

S H O W U S ? S H O W U S ?

slide-34
SLIDE 34
slide-35
SLIDE 35

Show me! REST / CRUD demo

slide-36
SLIDE 36

H O W I T W O R K S H O W I T W O R K S

slide-37
SLIDE 37

H O W A T R A D I T I O N A L H O W A T R A D I T I O N A L S T A C K W O R K S S T A C K W O R K S

slide-38
SLIDE 38
slide-39
SLIDE 39

H O W A T R A D I T I O N A L H O W A T R A D I T I O N A L S T A C K W O R K S S T A C K W O R K S

slide-40
SLIDE 40
slide-41
SLIDE 41

H O W A T R A D I T I O N A L H O W A T R A D I T I O N A L S T A C K W O R K S S T A C K W O R K S

slide-42
SLIDE 42
slide-43
SLIDE 43

H O W A T R A D I T I O N A L H O W A T R A D I T I O N A L S T A C K W O R K S S T A C K W O R K S

slide-44
SLIDE 44
slide-45
SLIDE 45

H O W A T R A D I T I O N A L H O W A T R A D I T I O N A L S T A C K W O R K S S T A C K W O R K S

slide-46
SLIDE 46
slide-47
SLIDE 47

H O W A T R A D I T I O N A L H O W A T R A D I T I O N A L S T A C K W O R K S S T A C K W O R K S

slide-48
SLIDE 48
slide-49
SLIDE 49

T H E O V E R H E A D I S H I G H T H E O V E R H E A D I S H I G H

slide-50
SLIDE 50

P A Y F O R I T P A Y F O R I T N T I M E S T I M E S

slide-51
SLIDE 51

W H I L E I N Q U A R K U S : W H I L E I N Q U A R K U S :

B U I L D T I M E B O O T B U I L D T I M E B O O T

As much work as possible done at build time Output: recorded wiring bytecode Heap & state can be captured by the GraalVM native-image compiler

slide-52
SLIDE 52

W H I L E I N Q U A R K U S W H I L E I N Q U A R K U S

slide-53
SLIDE 53

E X T E N S I O N S M O D E L E X T E N S I O N S M O D E L

Each framework/library needs an extension to apply these benefits

  • Can physically avoid shipping some bootstrap-

preparation only code

  • Is Quarkus a meta-build tool?
slide-54
SLIDE 54

E X T E N S I O N S M O D E L E X T E N S I O N S M O D E L

Can physically avoid shipping some code

slide-55
SLIDE 55

J A N D E X J A N D E X

High performance classpath scanner & indexer: avoids any class initialization

slide-56
SLIDE 56

A R C A R C

CDI based dependency injection, at build time

slide-57
SLIDE 57

G I Z M O G I Z M O

Bytecode generation library, used by extensions to generate all infrastructure

slide-58
SLIDE 58

D E S I G N C O N S E Q U E N C E S D E S I G N C O N S E Q U E N C E S

Less classes are loaded

  • Can physically avoid shipping some bootstrap-

preparation only code

  • Overhead not repeated on each container boot
  • Far easier to get working in GraalVM native

images - and better optimised code!

slide-59
SLIDE 59

C o r e + E x t e n s i o n s C o r e + E x t e n s i o n s

slide-60
SLIDE 60

D E V E L O P E R ' S J O Y ? D E V E L O P E R ' S J O Y ?

slide-61
SLIDE 61
slide-62
SLIDE 62

Show me! Demo #2

slide-63
SLIDE 63

Q U A R K U S E X T E N S I O N S Q U A R K U S E X T E N S I O N S

Required for frameworks that hit GraalVM limitations

  • Opportunity to highly optimise also for JVM
  • Code strictly separates build time analysis and

runtime: extremely lean output!

slide-64
SLIDE 64

W H A T C A N A N W H A T C A N A N E X T E N S I O N D O ? E X T E N S I O N D O ?

Invoke Quarkus helpers to dynamically Interact with the GraalVM compiler needs

  • Generate "Bootstrap at build" initializers
  • Much much more... and evolving
slide-65
SLIDE 65

S O , W H E R E ' S T H E S O , W H E R E ' S T H E C A T C H ? C A T C H ?

slide-66
SLIDE 66

N O P E R F O R M A N C E N O P E R F O R M A N C E C O M P R O M I S E S C O M P R O M I S E S

slide-67
SLIDE 67

&

slide-68
SLIDE 68

A o T c o m p i l a t i o n w i t h G r a a l V M A o T c o m p i l a t i o n w i t h G r a a l V M

Application classes JDK API classes SubstrateVM classes Staticaly linked executable

slide-69
SLIDE 69

A o T c o m p i l a t i o n w i t h G r a a l V M A o T c o m p i l a t i o n w i t h G r a a l V M

Static analysis

  • Closed world assumption
  • Aggressive dead code elimination
slide-70
SLIDE 70

L I M I T A T I O N S L I M I T A T I O N S

O F G R A A L V M N A T I V E O F G R A A L V M N A T I V E I M A G E S I M A G E S

slide-71
SLIDE 71

D Y N A M I C C L A S S L O A D I N G D Y N A M I C C L A S S L O A D I N G

slide-72
SLIDE 72

D Y N A M I C C L A S S L O A D I N G D Y N A M I C C L A S S L O A D I N G

Deloying jars, wars, etc. at runtime impossible

slide-73
SLIDE 73

J V M T I , J M X J V M T I , J M X

+ other native VM interfaces No agents JRebel, Byteman, profilers, tracers, ... No Java Debugger

slide-74
SLIDE 74

R E F L E C T I O N R E F L E C T I O N

Requires registration via native-image CLI/API

! limited

slide-75
SLIDE 75

M O R E . . . M O R E . . .

Need to register in advance also:

! limited

Dynamic proxies

  • Resources being loaded
  • JNI, Unsafe Memory Access, ...
slide-76
SLIDE 76

S T A T I C I N I T S T A T I C I N I T

Attempts to run them at build time

Very special

Resolve classes, run "safe" static initializers

  • Take a snapshot of the produced instances -

prune the unreachable ones

  • Include needed state in the executable
slide-77
SLIDE 77

S T A T I C I N I T S T A T I C I N I T

Very special

not allowed: file handles, sockets, threads

  • careful with other state: timestamps, system

dependent constants, capturing environment variables, etc..

slide-78
SLIDE 78

H O W D O Y O U D I S A B L E A H O W D O Y O U D I S A B L E A F E A T U R E A N Y W A Y ? F E A T U R E A N Y W A Y ?

slide-79
SLIDE 79

H O W D O Y O U D I S A B L E A H O W D O Y O U D I S A B L E A F E A T U R E A N Y W A Y ? F E A T U R E A N Y W A Y ?

boolean jmxEnabled = parseConfiguration(...); if (jmxEnabled) { registerJMX(); }

slide-80
SLIDE 80

H O W D O Y O U D I S A B L E A H O W D O Y O U D I S A B L E A F E A T U R E A N Y W A Y ? F E A T U R E A N Y W A Y ?

boolean jmxEnabled = parseConfiguration(...); if (jmxEnabled) { registerJMX(); } static final JMX_ENABLED = false; if (JMX_ENABLED) { registerJMX(); }

slide-81
SLIDE 81

T H I N K T W I C E B E F O R E T H I N K T W I C E B E F O R E S T A R T I N G . . . S T A R T I N G . . .

slide-82
SLIDE 82

T H I N K T W I C E B E F O R E T H I N K T W I C E B E F O R E S T A R T I N G . . . S T A R T I N G . . .

All your dependencies need to get compiled too!

slide-83
SLIDE 83

T H I N K T W I C E B E F O R E T H I N K T W I C E B E F O R E S T A R T I N G . . . S T A R T I N G . . .

All your dependencies need to get compiled too! ALL REACHABLE CODE

slide-84
SLIDE 84

T H I N K T W I C E B E F O R E T H I N K T W I C E B E F O R E S T A R T I N G . . . S T A R T I N G . . .

All your dependencies need to get compiled too! ALL REACHABLE CODE ALL DEPENDENCIES

slide-85
SLIDE 85

T H I N K T W I C E B E F O R E T H I N K T W I C E B E F O R E S T A R T I N G . . . S T A R T I N G . . .

Might be wiser to contribute to an open community of per-dependency extensions? All Quarkus code is Apache License v.2

slide-86
SLIDE 86

Q U A R K U S W R A P U P Q U A R K U S W R A P U P

Java suited for clouds and containers! Good old Java

More fun, less weight

Can go small as Go, works great on JVM too

slide-87
SLIDE 87

N A T I V E I M A G E N A T I V E I M A G E P E R F O R M A N C E P E R F O R M A N C E

Slightly lower than JVM Yet a winner in some conditions:

slide-88
SLIDE 88

N A T I V E I M A G E N A T I V E I M A G E P E R F O R M A N C E P E R F O R M A N C E

Slightly lower than JVM Yet a winner in some conditions: high memory density

slide-89
SLIDE 89

N A T I V E I M A G E N A T I V E I M A G E P E R F O R M A N C E P E R F O R M A N C E

Slightly lower than JVM Yet a winner in some conditions: high memory density no warmup needed!

slide-90
SLIDE 90

N A T I V E I M A G E N A T I V E I M A G E P E R F O R M A N C E P E R F O R M A N C E

Slightly lower than JVM Yet a winner in some conditions: high memory density no warmup needed! instant elastic response / lambda support

slide-91
SLIDE 91

N A T I V E I M A G E N A T I V E I M A G E P E R F O R M A N C E P E R F O R M A N C E

Slightly lower than JVM Yet a winner in some conditions: high memory density no warmup needed! instant elastic response / lambda support Bonus: you don't have to make a choice upfront.

slide-92
SLIDE 92

T H A N K Y O U ! T H A N K Y O U !

Q & A Q & A

Docs & guides:

quarkus.io Chat:

quarkusio.zulipchat.com Quickstarts:

github.com/quarkusio/quarkus-quick Stack Overflow tag:

quarkus Twitter:

@quarkusio