1 of 48

Quarkus: Fast, Small, Innovative, and Native?

Link

rafael.benevides@oracle.com

@rafabene - bit.ly/quarkus

2 of 48

Rafael Benevides

Cloud-Native Developer Advocate

rafael.benevides@oracle.com

@rafabene

Java Certifications:

SCJA / SCJP / SCWCD / SCBCD / SCEA

JBoss Certifications:

JBCD / JBCAA

Red Hat Certifications:

OpenShift / Containers / Ansible

Other Certifications:

SAP Netweaver / ITIL / IBM Software Quality

@rafabene - bit.ly/quarkus

3 of 48

3

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |

@rafabene - bit.ly/quarkus

4 of 48

4

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |

@rafabene - bit.ly/quarkus

5 of 48

@rafabene - bit.ly/quarkus

6 of 48

6

QUARKUS.IO

@rafabene - bit.ly/quarkus

7 of 48

@rafabene - bit.ly/quarkus

8 of 48

@rafabene - bit.ly/quarkus

9 of 48

@rafabene - bit.ly/quarkus

10 of 48

@rafabene - bit.ly/quarkus

11 of 48

@rafabene - bit.ly/quarkus

12 of 48

@rafabene - bit.ly/quarkus

13 of 48

@rafabene - bit.ly/quarkus

14 of 48

@rafabene - bit.ly/quarkus

15 of 48

@rafabene - bit.ly/quarkus

16 of 48

2007

KVM

2009

DEVOPS

@rafabene - bit.ly/quarkus

17 of 48

$18,000 Sun Sparc App Server Box (4 CPUs, 2GB of RAM)

+ $60,000 BEA Weblogic

+ $92,000 Sun Spark DB Server Box (8 CPUs)

+ $243,000 Oracle RDBMS

+ $50,000 Symantec Visual Café for 10 developers

--------------------------------------------------

$463,000 (capex) + ~$80,000 annual maint (opex)

Cost of a Java-based Web App circa 1999

@rafabene - bit.ly/quarkus

18 of 48

@rafabene - bit.ly/quarkus

19 of 48

— nutrecht July 2018

@rafabene - bit.ly/quarkus

20 of 48

Meet Quarkus

Supersonic java

@rafabene - bit.ly/quarkus

21 of 48

Quark any of a number of subatomic particles carrying a fractional electric charge

And "us"

(hardest problem in software)

WTF

is a

Quarkus ?

@rafabene - bit.ly/quarkus

22 of 48

Build a new Project

mvn io.quarkus:quarkus-maven-plugin:1.1.1.Final:create

@rafabene - bit.ly/quarkus

23 of 48

Quarkus Build process

@rafabene - bit.ly/quarkus

24 of 48

  • Moved as much as possible to build phase
  • Minimized runtime dependencies
  • Maximize dead code elimination
  • Introduced clear metadata contracts
  • Spectrum of optimization levels

(all -> some -> no runtime reflection)

Optimizations benefit both GraalVM (SVM) and HotSpot

Framework Optimizations

@rafabene - bit.ly/quarkus

25 of 48

Build a native binary

mvn clean package -Pnative

@rafabene - bit.ly/quarkus

26 of 48

@rafabene - bit.ly/quarkus

27 of 48

@rafabene - bit.ly/quarkus

28 of 48

GraalVM Limitations

  • Dynamic Class Loading
    • Deploy JARS, WARS at Runtime is impossible

  • JVMTI, JMX + Other native VM interfaces
    • No Agents -> No JRebel, Byteman, profilers, tracers

  • Others
    • Security Manager
    • finalize() (deprecated anyway)
    • InvokeDynamic and MethodHandler

@rafabene - bit.ly/quarkus

29 of 48

GraalVM Limitations

  • Reflection (LIMITED)
    • Requires registration
    • -H:ReflectionConfigurationFiles=/path/to/reflectconfig

@rafabene - bit.ly/quarkus

30 of 48

@rafabene - bit.ly/quarkus

31 of 48

@rafabene - bit.ly/quarkus

32 of 48

@rafabene - bit.ly/quarkus

33 of 48

@rafabene - bit.ly/quarkus

34 of 48

@rafabene - bit.ly/quarkus

35 of 48

Build the Native Docker Image

mvn package -Pnative \

-Dquarkus.native.container-build=true

@rafabene - bit.ly/quarkus

36 of 48

Enough love to go around.

developer

@rafabene - bit.ly/quarkus

37 of 48

Imperative and reactive

Serverless

Live reload

Microservices

Fat jars and native executables

Optimized for JAX-RS & JPA (Hibernate) …

@rafabene - bit.ly/quarkus

38 of 48

@rafabene - bit.ly/quarkus

39 of 48

Connect to Database

quarkus.datasource.driver=com.mysql.cj.jdbc.Driver

quarkus.hibernate-orm.dialect=org.hibernate.dialect.MySQL5Dialect

quarkus.datasource.url=jdbc:mysql://localhost:3306/quarkus

quarkus.datasource.username = rafael

quarkus.datasource.password = 123456

quarkus.hibernate-orm.log.sql=true

quarkus.hibernate-orm.database.generation=update

@rafabene - bit.ly/quarkus

40 of 48

Kubernetes Native

@rafabene - bit.ly/quarkus

41 of 48

Build the Image

eval $(minikube docker-env)

or

export DOCKER_HOST=tcp://192.168.100.100:2375

docker build -f src/main/docker/Dockerfile.native -t myquarkus .

@rafabene - bit.ly/quarkus

42 of 48

Instantiate the Image

kubectl run myquarkus-app --image=meu-projeto --port=8080 --image-pull-policy=IfNotPresent

kubectl expose deployment myquarkus-app --type=NodePort

@rafabene - bit.ly/quarkus

43 of 48

Access the application

curl $(minikube service myquarkus-app --url)/hello

Or

curl 192.168.100.100:$(kubectl get svc myquarkus-app -o=jsonpath='{.spec.ports[?(@.port==8080)].nodePort}')/hello

@rafabene - bit.ly/quarkus

44 of 48

Image:

quay.io/images/custservice:1.1.0

Replicas:

20

Labels:

customerservice=prod,ci_build=1213

ConfigMap:

cust_config

@rafabene - bit.ly/quarkus

45 of 48

Run them on Linux

Virtual

Physical

Private

Public

Oracle Linux

Node

Node

Node

Master

API Server

Dev

Ops

SCM�(Git/Svn)

CI/CD

Automation

Controllers

- Scheduler

- Replication

- Services

- Builds

- Routes

- Deployment

Kubernetes

Ingress Gateway

46 of 48

10x smaller.

Up to 100x faster.

@rafabene - bit.ly/quarkus

47 of 48

@rafabene - bit.ly/quarkus

48 of 48

@RAFABENE

@rafabene - bit.ly/quarkus