Slide 1

Slide 1 text

@kevindubois Writing Serverless Apps using Knative and Quarkus Kevin Dubois, Principal Developer Advocate, Red Hat

Slide 2

Slide 2 text

@kevindubois Kevin Dubois ● Developer Advocate at Red Hat ● 18+ years of experience writing and delivering software ● Speak English, Dutch, French, Italian ● Passionate about improving Dev Experience with Open Source @kevindubois@mastodon.social youtube.com/@thekevindubois linkedin.com/in/kevindubois github.com/kdubois @kevindubois.com

Slide 3

Slide 3 text

@kevindubois The “good” old days

Slide 4

Slide 4 text

@kevindubois Cloud & Scaling Respond more quickly to demand Rolling deployments (canary | A/B | Blue-Green | shadow) High availability Grow your application in a manageable way Use only the resources you need ! >> €€ +

Slide 5

Slide 5 text

@kevindubois Serverless “Serverless computing refers to the concept of building and running applications that do not require server management. It describes a finer-grained deployment model where applications, bundled as one or more functions are uploaded to a platform and then executed, scaled, and billed in response to the exact demand needed at the moment” -- CNCF Definition, https://www.cncf.io/blog/2018/02/14/cncf-takes-first-step-towards-serverless-computing/

Slide 6

Slide 6 text

@kevindubois

Slide 7

Slide 7 text

@kevindubois Serverless Over provisioning Time in capacity planning IT cost of idle resources Under provisioning Lost business revenue Poor quality of service More applications Direct line between IT costs & business revenue NOT Serverless with Serverless

Slide 8

Slide 8 text

@kevindubois OpenShift Sandbox: Default to Serverless == Savings

Slide 9

Slide 9 text

@kevindubois Java?

Slide 10

Slide 10 text

@kevindubois Serverless Adoption 6.1% Java https://serverless.com/blog/2018-serverless-community-survey-huge-growth-usage/ 62.9% Node.js 20.8% Python 6.4% Go 6.1% Java 3.8% C#

Slide 11

Slide 11 text

@kevindubois

Slide 12

Slide 12 text

@kevindubois https://greenlab.di.uminho.pt/wp-content/uploads/2017/10/sleFinal.pdf Energy Efficiency across Programming Languages

Slide 13

Slide 13 text

@kevindubois JVM Scaling

Slide 14

Slide 14 text

@kevindubois When you can’t scale fast enough…

Slide 15

Slide 15 text

@kevindubois Build Time Runtime Packaging (maven, gradle, etc) Load config file from file system Parse it Classpath scanning to find annotated classes Attempt to load class to enable/disable features Build its model of the world. Start the management (thread, pool…) @ @ > How Does a Framework Start?

Slide 16

Slide 16 text

@kevindubois Build Time Runtime @ @ > Quarkus Runtime Build Time @ @ > Package model Build Time Runtime @ @ >

Slide 17

Slide 17 text

@kevindubois Quarkus enables Native Compilation JVM Build Time @ @ > Package model Native

Slide 18

Slide 18 text

@kevindubois Supersonic Subatomic Java Quarkus + Native (via GraalVM) 12 MB Quarkus + JVM (via OpenJDK) 73 MB Traditional Cloud-Native Stack 136 MB Quarkus + Native (via GraalVM) 0.016 Seconds Quarkus + JVM (via OpenJDK) 0.943 Seconds Traditional Cloud-Native Stack 4.3 Seconds

Slide 19

Slide 19 text

@kevindubois Serverless Quarkus

Slide 20

Slide 20 text

@kevindubois AWS Lambda, Functions... Built around the FaaS components and other services such as API Gateways. It enabled a variety of use cases but it is far from ideal for general computing and with room for improvements. 1.0 ➔ HTTP and other few Sources ➔ Functions only ➔ Limited execution time (5 min) ➔ No orchestration ➔ Limited local development experience

Slide 21

Slide 21 text

@kevindubois

Slide 22

Slide 22 text

@kevindubois

Slide 23

Slide 23 text

@kevindubois Writing cloud agnostic functions

Slide 24

Slide 24 text

@kevindubois FUNQY “Quarkus Funqy is part of Quarkus’s serverless strategy and aims to provide a portable Java API to write functions deployable to various FaaS environments like AWS Lambda, Azure Functions, Google Cloud Functions, Knative, and Knative Events (Cloud Events). It is also usable as a standalone service.”

Slide 25

Slide 25 text

@kevindubois $ quarkus create app -x funqy-amazon-lambda $ quarkus create app -x quarkus-funqy-google-cloud-functions $ quarkus create app -x quarkus-funqy-http …

Slide 26

Slide 26 text

@kevindubois AWS Lambda, Functions... Built around the FaaS components and other services such as API Gateways. It enabled a variety of use cases but it is far from ideal for general computing and with room for improvements. 1.0 ➔ HTTP and other few Sources ➔ Functions only ➔ Limited execution time (5 min) ➔ No orchestration ➔ Limited local development experience Serverless Containers With the advent of containers & Kubernetes, many frameworks and solutions started to auto-scale containers. Cloud providers created offerings using managed services completely abstracting Kubernetes APIs. 1.5 ➔ Fargate, Cloud Run, Container Instances ➔ Knative, KEDA, etc ➔ Kubernetes based auto-scaling ➔ Microservices and Functions ➔ Easier to debug & test locally ➔ Polyglot & Portable Serverless is evolving...

Slide 27

Slide 27 text

@kevindubois

Slide 28

Slide 28 text

@kevindubois Knative https://github.com/knative

Slide 29

Slide 29 text

@kevindubois $ kn func create -l quarkus myfunc $ kn func deploy $ kn service create myservice --image=xyz

Slide 30

Slide 30 text

@kevindubois Immutable revisions Deploy new features: performing canary, A/B or blue-green testing with gradual traffic rollout with no sweat and following best practices. Any programming language Use any programming language or runtime of choice. From Java, Python, Go and JavaScript to Quarkus, SpringBoot or Node.js. No need to configure number of replicas, or idling. Scale to zero when not in use, auto scale to thousands during peak, with built-in reliability and fault-tolerance. Automatic scaling Simplified developer experience to deploy applications/code on serverless containers abstracting infrastructure & focusing on what matters. Containers made easy Ready for the Hybrid Cloud Truly portable serverless running anywhere Kubernetes runs, that is on-premises or on any public cloud. Leverage data locality and SaaS when needed. prem aws azur e Event Driven Architectures Build loosely coupled & distributed apps connecting with a variety of built-in or third-party event sources or connectors powered by Operators. Knative is an Open Source, Cloud Agnostic Solution to build Serverless and Event Driven Applications Knative

Slide 31

Slide 31 text

@kevindubois AWS Lambda, Functions... Built around the FaaS components and other services such as API Gateways. It enabled a variety of use cases but it is far from ideal for general computing and with room for improvements. 1.0 ➔ HTTP and other few Sources ➔ Functions only ➔ Limited execution time (5 min) ➔ No orchestration ➔ Limited local development experience Serverless Containers With the advent of containers & Kubernetes, many frameworks and solutions started to auto-scale containers. Cloud providers created offerings using managed services completely abstracting Kubernetes APIs. 1.5 ➔ Fargate, Cloud Run, Container Instances ➔ Knative, KEDA, etc ➔ Kubernetes based auto-scaling ➔ Microservices and Functions ➔ Easier to debug & test locally ➔ Polyglot & Portable Integration & State The maturity and benefits of Serverless are recognized industry wide and it adds the missing parts to make pattern suitable for general purpose workloads and used on the enterprise. 2.0 ➔ Basic state handling ➔ Enterprise Integration Patterns ➔ Advanced Messaging Capabilities ➔ Blended with your PaaS ➔ Enterprise-ready event sources ➔ Solutions and outcome focused

Slide 32

Slide 32 text

@kevindubois

Slide 33

Slide 33 text

@kevindubois Knative Eventing Eventing is a set of APIs for routing events from Producers to Consumers (known as Sinks) CloudEvent specification allows for the creation of Serverless components that are driven by Event rather than Traffic

Slide 34

Slide 34 text

@kevindubois CloudEvents CNCF incubating project - https://cloudevents.io/ Provides a common event schema => Interoperability, portability Extensible through extension attributes SDKs for different programming languages Protocol-agnostic (HTTP, AMQP, MQTT, …) Wide adoption

Slide 35

Slide 35 text

@kevindubois Usage Patterns Source to Sink

Slide 36

Slide 36 text

@kevindubois Usage Patterns Channel and Subscription

Slide 37

Slide 37 text

@kevindubois Usage Patterns Broker and Trigger

Slide 38

Slide 38 text

@kevindubois Demo

Slide 39

Slide 39 text

@kevindubois Apache Camel

Slide 40

Slide 40 text

@kevindubois Demo

Slide 41

Slide 41 text

@kevindubois

Slide 42

Slide 42 text

@kevindubois

Slide 43

Slide 43 text

@kevindubois Free Developer e-Books! developers.redhat.com/e-books

Slide 44

Slide 44 text

@kevindubois Start exploring in the OpenShift Sandbox. Learn containers, Kubernetes, and OpenShift in your browser. developers.redhat.com/developer-sandbox Try Red Hat's products and technologies without setup or configuration.

Slide 45

Slide 45 text

@kevindubois github.com/kdubois/quarkus-knative-func

Slide 46

Slide 46 text

@kevindubois github.com/kdubois/CamelQuarkusVoter redhat-developer-demos.github.io/knative-tutorial

Slide 47

Slide 47 text

@kevindubois Thank you! @kevindubois@mastodon.social youtube.com/@thekevindubois linkedin.com/in/kevindubois github.com/kdubois @kevindubois.com