Kubernetes Native with Quarkus Ken Finnigan, Senior Principal Engineer RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Introductions

● Technical Lead for Eclipse MicroProfile at Red Hat ● Project Lead for SmallRye ○ Implements Eclipse MicroProfile ● Book Author ○ Enterprise Java Microservices Name: Ken Finnigan Role/team: MP/SmallRye Where you’re from: Boston (via Aus)

2 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

3 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

An Open Source stack to write Java apps

Cloud Native, Microservices, Serverless

4 Source: Insert source data here Insert source data here Insert source data here WHY QUARKUS?

5 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

The hidden truth about Java + containers

● Designed for throughputs (requests/s) ● Startup overhead ○ # of classes, bytecode, JIT ● Memory overhead ○ # of classes, metadata, compilation

Heap Metaspace off-heap

RSS

6 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

The hidden truth about Java + containers

HotSpot Heap NodeJS Go Go NodeJS Go Go HotSpot Heap NodeJS Go Go NodeJS Go Go HotSpot Heap NodeJS Go Go NodeJS Go Go HotSpot Heap NodeJS Go Go

Node Node Node

Container platform

7 WHAT IS QUARKUS?

QUARK: elementary particle / US: hardest thing in computer science

8 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Quarkus Benefits

Developer Joy Supersonic Subatomic Java

Unifies Best-of-breed

imperative and reactive libraries and standards

9 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Benefit No. 1: Developer Joy

A cohesive platform for optimized developer joy:

● Based on standards, but not limited ● Unified configuration ● Zero config, live reload in the blink of an eye ● Streamlined code for the 80% common usages, flexible for the 20% ● No-hassle native executable generation

10 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Benefit No. 2: Supersonic Subatomic Java

REST

Quarkus + AOT Quarkus + OpenJDK (JIT) Traditional Cloud-Native Stack 19 MB 77 MB 140 MB

11 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Benefit No. 2: Supersonic Subatomic Java

REST + CRUD

Quarkus + AOT Quarkus + OpenJDK (JIT) Traditional Cloud-Native Stack 35 MB 130 MB 218 MB

12 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Benefit No. 2: Supersonic Subatomic Java

REST Time to first response Quarkus + AOT 0.014 Seconds

Quarkus + OpenJDK 0.75 Seconds

Traditional Cloud-Native Stack 4.3 Seconds

REST + CRUD

Quarkus + AOT 0.055 Seconds

Quarkus + OpenJDK (JIT) 2.5 Seconds

Traditional Cloud-Native Stack 9.5 Seconds

13 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Benefit No. 3: Unifies Imperative and Reactive

@Inject @Inject @Channel(”kafka”) SayService say; Publisher reactiveSay;

@GET @GET @Produces(MediaType.TEXT_PLAIN) @Produces(MediaType.SERVER_SENT_EVENTS) public String hello() { public Publisher stream() { return say.hello(); return reactiveSay; } }

● Combine both reactive and imperative development in the same application ● Use the technology that fits your use case ● Key for reactive systems based on event-driven apps

14 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Benefit No. 4: Best of Breed Frameworks & Standards

Quarkus provides a cohesive, fun to use, full-stack framework by leveraging a growing list of over fifty best-of-breed libraries that you love and use. All wired on a standard backbone.

15 HOW QUARKUS WORKS

16 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Move startup time to build time

What does a framework do at startup time?

● Parse config files ● Classpath & classes scanning ○ for annotations, getters or other metadata ● Build framework metamodel objects ● Prepare reflection and build proxies ● Start and open IO, threads, etc

17 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Build time benefits

● Do the work once, not at each start ● All the bootstrap classes are no longer loaded ● Less time to start, less memory used ● Less or no reflection nor dynamic proxy

18 SPRING COMPATIBILITY

19 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Why Spring on Quarkus?

● Capitalize your Spring know-how

● Speed up knowledge transfer and onboarding

● Familiarity

20 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Spring DI and Web

● Spring DI and Web ○ Dependency injection model ■ @Component, @Autowired, etc. ○ Spring Web - Developing REST APIs ■ @RestController, etc.

● Spring Data JPA ○ Derived methods ○ Custom query methods ○ Fragments ○ Transactional support

21 NATIVE IMAGE

22 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Dead code elimination

Java Java Application Application Classes Classes

JDK JDK Native Classes Classes Executable

Substrate Substrate VM VM Classes Classes Closed-world assumption

23 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

When to use which VM with Quarkus?

JIT - OpenJDK HotSpot AOT - GraalVM native image

High memory-density requirements Highest memory-density requirements High request/s/MB Highest request/s/MB Fast startup time for low heap size usages Faster startup time Best raw performance (CPU) 10s of ms for Serverless Best garbage collectors Higher heap size usage

Known monitoring tools Compile Once, Run anywhere Libraries that only work in standard JDK

24 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019

Resources

● Demos ○ https://github.com/burrsutter/quarkus-todo-app ○ https://github.com/burrsutter/springtodo ● Quarkus ○ https://quarkus.io/ ○ https://code.quarkus.io/ ○ https://quarkusio.zulipchat.com/ ○ https://github.com/quarkusio/quarkus ○ https://twitter.com/quarkusio

25 CONFIDENTIAL Designator

Thank you linkedin.com/company/red-hat

youtube.com/user/RedHatVideos Red Hat is the world’s leading provider of

enterprise open source software solutions. facebook.com/redhatinc Award-winning support, training, and consulting

services make twitter.com/RedHat Red Hat a trusted adviser to the Fortune 500.

26 RED HAT DALLAS EMERGING TECH SUMMIT - DEC 5, 2019 - DEC SUMMIT TECH EMERGING DALLAS RED HAT STAY ENGAGED Developers. redhat.com Your access point for no-cost developer tools and product subscriptions, how-tos, and demos

Red Hat User Groups Meetups for networking and tech deep dives www.meetup.com/Dallas-Red-Hat-Users-Group/

DevNation Virtual and live events Catch replays at https://developers.redhat.com/devnation/

Next.redhat.com Stay in touch with the Office of the CTO

27