Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty...

1

Transcript of Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty...

Page 1: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting
Page 2: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Quarkus Supersonic Subatomic Java Stuart Douglas, Principal Software Engineer Red Hat

Page 3: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Employed by Red Hat since 2011 • Quarkus Co-Founder • Undertow Founder • Core contributor to WildFly • Servlet Spec Co-Lead

About Me

@stuartwdouglas

github.com/stuartwdouglas

Page 4: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Quarkus: A Java Stack Designed for Cloud Native Development

Page 5: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

4

Quark a subatomic particle carrying a fractional electric charge And us (the heart of software development)

WHAT’S

in a

NAME?

Quarkus

Page 6: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• A standards based platform that prioritises developer experience, startup speed and memory usage

• Optimised for cloud use cases • Built on mature libraries such as

Hibernate and RESTeasy • Allows for compilation to native code via

GraalVM

What is it?

Page 7: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Easy to get started • Familiar API’s • Unified Configuration • Convention over configuration • Focus on documentation • Remove boilerplate

Designed for Developers

Page 8: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Developer Mode mvn compile quarkus:dev

Page 9: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Lets you connect to a container running

in dev mode in the cloud • Changes made locally take effect

instantly

Cloud Native Development

mvn compile quarkus:remote-dev

Page 10: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Demo

Page 11: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

10

Evolving Java For Containers and Serverless

Page 12: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

11

ENTERPRISE JAVA WAS DESIGNED FOR 3-TIER ARCHITECTURE

APPLICATION SERVER / JVM

HTML Javascript Web

Cart Catalog Inventory

Promo Ratings Orders

Data Access

Presentation Logic

Business Logic

Data Access Logic

OPERATING SYSTEM

Page 13: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

12

HOW APPLICATION SERVERS DEPLOYED JAVA APPS

APPLICATION SERVER / JVM

HTML Javascript Web

Cart Catalog Inventory

Promo Ratings Orders

Data Access

OPERATING SYSTEM

HTML Javascript Web

Cart Catalog Inventory

Promo Ratings Orders

Data Access

Page 14: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

13

Microservices changed how we write apps

Microservice

Microservice

Microservice

Microservice

Microservice

Microservice

Microservice

Microservice

Microservice

Kubernetes

Page 15: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

14

And serverless/FAAS will change it even more

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Function

Page 16: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

15

The hidden truth about Java in containers

CONTAINER ORCHESTRATION

Node Node Node

Traditional Cloud-Native Java Stack

Traditional Cloud-Native Java Stack

Traditional Cloud-Native Java Stack

Traditional Cloud-Native Java Stack

NodeJS

NodeJS

NodeJS

NodeJS

NodeJS

NodeJS

NodeJS

Go Go Go

Go Go Go

Go Go Go

Go Go Go

Go Go Go

Go Go Go

Go Go Go

https://developers.redhat.com/blog/2017/03/14/java - inside-docker/

Page 17: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

16

The hidden truth about Java in contains

Total Memory (RSS)

Metaspace Heap Off Heap

Only the heap is available to your application at runtime

Page 18: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

17

THE HIDDEN TRUTH ABOUT JAVA IN CONTAINERS

CONTAINER ORCHESTRATION

Node Node Node

NodeJS

NodeJS

NodeJS

NodeJS

NodeJS

NodeJS

NodeJS

Go Go Go

Go Go Go

Go Go Go

Go Go Go

Go Go Go

Go Go Go

Go Go Go

https://developers.redhat.com/blog/2017/03/14/java - inside-docker/

Hotspot Heap

Hotspot Heap

Hotspot Heap

Hotspot Heap

Page 19: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Complex Management Infrastructure • Remote Management • Hot Deployment of Applications • Full Java EE Stack • Patching

You are deploying features you don’t need

But you still pay for them in memory usage and startup time

Page 20: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Still one of the most popular languages • Java has a massive amount of mature and

tested frameworks and libraries • Companies have made a massive

investment in Java • These problems are not with Java itself, but

they way it has traditionally been used

Why Java?

Page 21: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

20

Comparisons

100x faster startup, 10% of the memory in native mode

5 x faster and ½ the of the memory on Hotspot/ OpenJ DK

Page 22: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Native Compilation?

$ ls -l hibernate-orm-resteasy-1.0-SNAPSHOT-runner -rwxr-xr-x 1 stuart staff 54245792 17 Apr 12:43 hibe...

INFO Quarkus 0.13.2 started in 0.029s. Listening on: http://127.0.0.1:8080 INFO Installed features: [agroal, cdi, hibernate-orm, jdbc-postgresql, narayana-jta, resteasy, resteasy-jsonb]

Page 23: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Quarkus solves the Java density and startup time problems

• This mean less memory usage and lower costs

• Native mode takes it even further

Quarkus and the cloud

Page 24: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

23

Developer Experience

Page 25: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• CDI • JAX-RS • JPA • Bean Validation • Websockets • Transactions • Servlet

Familiar Standards

• Config • REST Client • Health Check • Reactive Streams • OpenAPI • OpenTracing • ...

Page 26: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• We aim to be standards based as much as possible

• Unless following the standard unduly impacts: • Developer experience • Startup Time • Memory usage

• Then we will innovate and try and change the standard

Approach to Standards

Page 27: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• We are not implementing EJB, but will add similar functionality

• @TransactionAttribute -> @Transactional

• Remote Interfaces -> GRPC • Declarative Security -> CDI Interceptor

No EJB

Page 28: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

JPA Automatic Activation

• No persistence.xml required • If you include JPA, have a datasource, and

some Entities we auto configure it • No Resource Producer fields required

Page 29: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Arc: Build Time CDI

• Arc is a new implementation of CDI that resolves all injection points at build time

• Mostly reflection free • Fast startup and low memory use

Page 30: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Portable Extensions allow you to modify any application metadata at startup

• This is not compatible with build time processing

• We have implemented our own build time extension mechanism, and once it has matured we will aim to standardise it

Example: CDI Portable Extensions

Page 31: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Panache (Simplified JPA) • Vert.x • Apache Camel • Apache Kafka • Kotlin Support • Scheduling

More than just standards

Page 32: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

31

UNIFIES IMPERATIVE AND REACTIVE

Combine both Reactive and imperative development in the same application Inject the E ventB us or the Vertx context Use the technology that fits your use-case

Page 33: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Demo

Page 34: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

How Does it Work?

Page 35: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

QUARKUS BUILD PROCESS

Compile Provision Augment Compile to Native

Page 36: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• As much processing is possible is done at

build time • Don’t do annotation or descriptor

processing at boot time • Result is written out as generated

bytecode

Build Process

Page 37: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting
Page 38: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Almost all Quarkus functionality is

implemented as extensions • Extensions consist of two parts, runtime

and deployment time • Only the runtime part ends up in the

final application

Extensions

Page 39: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Anatomy of an Extension

Deployment • Processes annotations,

config and other metadata • Outputs generated bytecode

to start the runtime components

• Injection based • No knowledge of bytecode

required

Runtime • Runs the bytecode

generated at build time • Starts runtime services • Should only contain what is

needed at runtime

Page 40: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Polyglot, Native or JVM, Embeddable

Page 41: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Quarkus Native Deployment

CONTAINER ORCHESTRATION

Node Node

Traditional Cloud -Native Java Stack

Traditional Cloud -Native Java Stack

Traditional Cloud -Native Java Stack

Traditional Cloud -Native Java Stack

Quarkus Quarkus Quarkus

Quarkus Quarkus Quarkus

Quarkus Quarkus Quarkus

Quarkus Quarkus Quarkus

Quarkus Quarkus Quarkus

Quarkus Quarkus Quarkus

Quarkus Quarkus Quarkus

Quarkus Quarkus

Quarkus Quarkus

Quarkus Quarkus

Quarkus Quarkus

Quarkus Quarkus

Quarkus Quarkus

Quarkus Quarkus

Quarkus Quarkus Quarkus Quarkus Quarkus

Page 42: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

JVM CI

S ulong (LLVM)

Truffle

Graal Compiler

S ubstrate VM

J ava HotS pot VM

Page 43: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Compiles Java applications to a native executable

• Has some limitations that make it hard to use out of the box

• Quarkus works around those limitations so you don’t have to

GraalVM

Page 44: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Closed World, no dynamic class loading • All reflection usage must be declared at

build time • Various other things unsupported

Limitations

Page 45: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Developing Native Applications with SubstrateVM Can be Painful

Quarkus handles this for you

Page 46: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

$ mvn quarkus:native-image

Building Native Images

• Quarkus will analyse your application, and give GraalVM all the information it needs to build an executable

• Also provides @RegisterForReflection

Page 47: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

Quarkus makes Java run better in Serverless and Container Environments

Page 48: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Quarkus is still a very young project • We have a lot planned

Future Plans

Page 49: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• We are looking at ways to make it easy to discover and consume third party extension

• There should be no real difference between extensions provided by the core team and third party ones

Extension Ecosystem

Page 50: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Building a Quarkus app is not really part of the build, it happens after

• It should be possible to easily update running apps to latest version, without rebuilding

Post Build Updates

Page 51: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

• Undertow 3 will use Netty as the underlying transport

• This will allow us to share resources better, resulting in lower memory usage

• Also allows Vert.x and Undertow endpoints to share a port

I/O Alignment

Page 52: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting

http://quarkus.io

Resources

@stuartwdouglas

github.com/stuartwdouglas

github.com/quarkusio

@quarkusio

Page 53: Quarkus Supersonic Subatomic Java - DeveloperMarch · 2019-05-17 · • Undertow 3 will use Netty as the underlying transport • This will allow us to share resources better, resulting