SlideShare a Scribd company logo
1 of 57
Download to read offline
Serverless Java on Kubernetes
Krzysztof Sobkowiak (@ksobkowiak)
https://blog.cdemi.io/what-is-serverless-architecture/
Wrocław, 01.03.2019
#TechTalkSE
About me
● Capgemini
○ Senior Delivery Architect, Trainer
○ JEE & OSS solutions, system integration, cloud, microservices,
devops
● Apache Software Foundation
○ Member
○ Apache ServiceMix Committer & PMC Chair (V.P. ServiceMix)
○ Contributor @ Apache Karaf, Apache CXF, Apache Camel,
Apache ActiveMQ
● Co-organizer of #geekweekwro
Views in this presentation are my personal views and do not necessarily reflect the views of Capgemini or The Apache Software Foundation.
https://wspolczesna.pl/koniec-swiata-1-lutego-asteroida-2002-nt7-uderzy-w-ziemie-jasnowidz-z-czluchowa-komentuje-01022019/ar/13852986
Monolith
http://bit.ly/serverlessjavajbcn
Microservices
http://bit.ly/serverlessjavajbcn
https://redmonk.com/jgovernor/2016/10/12/when-web-companies-grow-up-they-turn-into-java-shops/
https://redmonk.com/sogrady/2018/08/10/language-rankings-6-18/
Functions
http://bit.ly/serverlessjavajbcn
What is 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.”
https://www.cncf.io/blog/2018/02/14/cncf-takes-first-step-towards-serverless-computing/
What is serverless?
“Serverless architectures are application designs that
incorporate third-party “Backend as a Service” (BaaS)
services, and/or that include custom code run in managed,
ephemeral containers on a “Functions as a Service” (FaaS)
platform.”
https://martinfowler.com/articles/serverless.html
Function as a Service (FaaS)
● Function
○ Small bits of code with a well defined job
○ Easy to understand and maintain
● As a service
○ The system takes care of provisioning, scaling, patching, …
○ Each function can scale independently
fx
https://serverless.com/blog/serverless-by-the-numbers-2018-data-report/
https://serverless.com/blog/serverless-by-the-numbers-2018-data-report/
FaaS Kubernetes & Java support
Apache OpenWhisk
https://openwhisk.apache.org/
Integrate with many popular services
https://openwhisk.apache.org/
Deploys anywhere
https://openwhisk.apache.org/
How does it work?
https://medium.com/openwhisk/uncovering-the-magic-how-serverless-platforms-really-work-3cb127b05f71
OpenWhisk & Containers
wsk action invoke docker run
≈
OpenWhisk & Containers
Start container
docker run
Initialize
/init
Run
/run
https://medium.com/openwhisk/squeezing-the-milliseconds-how-to-make-serverless-platforms-blazing-fast-aea0e9951bd0
OpenWhisk & Containers
cold
Start container
docker run
Initialize
/init
Run
/run
https://medium.com/openwhisk/squeezing-the-milliseconds-how-to-make-serverless-platforms-blazing-fast-aea0e9951bd0
OpenWhisk & Containers
cold pre-warmed, paused
Start container
docker run
Initialize
/init
Run
/run
https://medium.com/openwhisk/squeezing-the-milliseconds-how-to-make-serverless-platforms-blazing-fast-aea0e9951bd0
OpenWhisk & Containers
cold pre-warmed, paused hot
Start container
docker run
Initialize
/init
Run
/run
https://medium.com/openwhisk/squeezing-the-milliseconds-how-to-make-serverless-platforms-blazing-fast-aea0e9951bd0
OpenWhisk & Containers
cold pre-warmed, paused hot
Start container
docker run
Initialize
/init
Run
/run
fasterhttps://medium.com/openwhisk/squeezing-the-milliseconds-how-to-make-serverless-platforms-blazing-fast-aea0e9951bd0
Programming model
JSON
Trigger
FeedEvent source
Rule
Action
● Basic unit of work
● A stateless, relatively short-running function
● Invoked as an event handler.
● Invoking an action generates an "activation id",
used to retrieve results
Action
JSONJSON
Supported languages
https://openwhisk.apache.org/
Action - JavaScript
function main(params) {
return { payload: 'Hello ' + params.body.text +
' from JavaScript action on OpenWhisk on OpenShift '};
}
Creating an action
To create an action, we need to we need to give it a name and configure it in
OpenWhisk
$ wsk -i action create msgaction msgaction.js
Invoking an action
Once it has a name, it can be invoked directly:
$ wsk -i action invoke msgaction --param body '{"text":"Tech Talk SE"}' --result
{ "payload": "Hello Tech Talk SE from JavaScript action on OpenWhisk on OpenShift" }
$ wsk -i activation get -l # see the details, logs
Action - Python
def main(params):
return { "payload" :
"Hello " + str(params["body"]["text"]) +
" from Python action on OpenWhisk on OpenShift"}
Updating an action
$ wsk -i action update msgaction msgaction.py
$ wsk -i action invoke msgaction --param body '{"text":"Tech Talk SE"}' --result
{ "payload": "Hello Tech Talk SE from Python action on OpenWhisk on OpenShift" }
Creating an action
packages:
demo:
actions:
msgaction:
function: msgaction.js
$ wskdeploy -m manifest-msgaction.yml
● Wide choice of good tooling
● “Plain old Java”
● Ability to build complex applications
● Low latency/high performance
● Serverless JVM
Blueprints for Serverless Java
Action - Java (POF)
public static JsonObject main(JsonObject params) {
JsonObject response = new JsonObject();
response.addProperty("payload", "Hello " +
params.getAsJsonObject("body").get("text").getAsString() +
" from Java action on OpenWhisk on OpenShift " );
return response;
}
Action - Java
$ wsk -i action update msgaction target/msgaction.jar --main com.example.FunctionMain
$ wsk -i action invoke msgaction --param body '{"text":"Tech Talk SE"}' --result
{ "payload": "Hello Tech Talk SE from Java action on OpenWhisk on OpenShift" }
$ mvn clean package
Spring Cloud Functions (SCF)
Spring Boot
Spring Cloud Function
Web
Spring Cloud Function
Webflux
Spring Cloud Stream
HTTP Message
Serverless Platforms Adapters
FaaS Provides
Spring Cloud Function Adapter
HTTP Message
Spring Cloud Functions (SCF)
@SpringBootApplication
public class Application {
@Bean
public Function<Flux<String>, Flux<String>> uppercase() {
return flux -> flux.map(value -> value.toUpperCase());
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
● Wide choice of good tooling → Maven, Gradle, IDE,...
● “Plain old Java” → POF
● Ability to build complex applications → SCF
● Low latency/high performance →pre-warmed containers,
OpenJ9, CDS, AOT
● Serverless JVM → OpenJ9
Blueprints for Serverless Java
Demo - Java Action
bit.ly/faas-tutorial
Serverless Microservices - web actions & api gateway
● Actions invoked via urls using HTTP
verbs like GET, POST, PUT, …
● Automatic content detection via
prefixing
● Api Gateway - proxy to Web Actions
○ HTTP method routing
○ client id/secrets
○ rate limiting
○ CORS
https://github.com/rabbah/wsk-qr
Web Actions & API Gateway
$ wsk -i action create fibonacci fibonacci.js --web true
$ WEB_URL=`wsk -i action get --url fibonacci | awk 'FNR==2{print $1}'`
$ curl -k $WEB_URL.json?num=5
$ wsk -i api create /fibonacci get fibonacci
$ curl -X GET ${API_URL}/api/${GENERATED_API_ID}/fibonacci?num=5
API Gateway
wsk api create -n "Book Club" /club /books/{isbn} get getBooks
wsk api create /club /books get getBooks
wsk api create /club /books post postBooks
wsk api create /club /books/{isbn} put putBooks
wsk api create /club /books/{isbn} delete deleteBooks
Demo - Web Action
Action Composition
https://openwhisk.apache.org/
● Pre-defined chain of actions
○ Sequences
● Determined dynamically
○ Conductors
○ Composer
● Output of previous step is input
of the next one
● Only first function in Sequence
can accept parameter
Action Sequence
$ wsk action create mySequence 
--sequence /whisk.system/utils/split,/whisk.system/utils/sort
$ wsk action invoke 
--result mySequence 
--param payload "Java,Python,Swift,JavaScript,Ruby,C" 
--param separator ','
Demo - Action Chaining
Event Driven Capabilities
● Triggers are channels for events
● Triggers can be linked, via rules, to one or more actions
● Events could be
○ Another function
○ External event source called as Feed Provider
● Trigger can be registered to Event Provider via Feeds (Stream of Events)
○ Feed can be:
■ Polling
■ Webhook
■ Persistent Connection JSON
Trigger & Rules
$ wsk -i trigger create every-5-seconds 
--feed /whisk.system/alarms/alarm 
--param cron '*/5 * * * * *' 
--param maxTriggers 25 
--param trigger_payload "{"name":"Tech Talk SE","place":"Wroclaw"}"
$ wsk -i rule create invoke-periodically 
every-5-seconds 
/whisk.system/samples/greeting
$ wsk -i activation poll
Demo - Triggers & Rules
Knative
Knative & OpenWhisk
Kubernetes
Foundational container scheduling and infrastructure management
Cluster Management Capacity Management Network Management Consistent & repeatable deployment
OpenWhisk
Serverless abstractions (actions, triggers, rules, etc) & multi-tenancy
Higher level abstractions (action, trigger, rule) API gateway & management
CLI & dev tools
Multi-tenancy
High level control flow logic
Throttles Web Actions
Autoscaling Eventing Routing Code → Container conversion
Serverless infrastructure building blocks & routing
Knative
https://www.ibm.com/blogs/cloud-computing/2018/07/24/ibm-cloud-google-knative-serverless/
thanks!
@ksobkowiakkrzysztof.sobkowiak@capgemini.com
http://bit.ly/serverlessjava-ttse
Credits
Special thanks to all the people who made and released their awesome resources
for free:
● Serverless Java: Challenges and Triumphs by David Delabassee
● Serverless Java on Kubernetes by Burr Sutter and Rafael Benevides
● Functions as a Service with Apache OpenWhisk and Openshift by Brendan
McAdams
● Your Journey into the Serverless World by Kamesh Sampath

More Related Content

What's hot

Design & Performance - Steve Souders at Fastly Altitude 2015
Design & Performance - Steve Souders at Fastly Altitude 2015Design & Performance - Steve Souders at Fastly Altitude 2015
Design & Performance - Steve Souders at Fastly Altitude 2015Fastly
 
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...Luciano Mammino
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Matthew Groves
 
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...DynamicInfraDays
 
Bulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & CouchbaseBulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & CouchbaseAlex Derkach
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and FriendsYun Zhi Lin
 
Dropwizard and Groovy
Dropwizard and GroovyDropwizard and Groovy
Dropwizard and Groovytomaslin
 
Dropwizard Introduction
Dropwizard IntroductionDropwizard Introduction
Dropwizard IntroductionAnthony Chen
 
Forensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance InvestigationsForensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance InvestigationsNicholas Jansma
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaYevgeniy Brikman
 
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
EWD 3 Training Course Part 14: Using Ajax for QEWD MessagesEWD 3 Training Course Part 14: Using Ajax for QEWD Messages
EWD 3 Training Course Part 14: Using Ajax for QEWD MessagesRob Tweed
 
Play + scala + reactive mongo
Play + scala + reactive mongoPlay + scala + reactive mongo
Play + scala + reactive mongoMax Kremer
 
Service Worker - Reliability bits
Service Worker - Reliability bitsService Worker - Reliability bits
Service Worker - Reliability bitsjungkees
 
Grails Launchpad - From Ground Zero to Orbit
Grails Launchpad - From Ground Zero to OrbitGrails Launchpad - From Ground Zero to Orbit
Grails Launchpad - From Ground Zero to OrbitZachary Klein
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocketMing-Ying Wu
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaJames Falkner
 
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...Codemotion
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with DropwizardAndrei Savu
 

What's hot (20)

Design & Performance - Steve Souders at Fastly Altitude 2015
Design & Performance - Steve Souders at Fastly Altitude 2015Design & Performance - Steve Souders at Fastly Altitude 2015
Design & Performance - Steve Souders at Fastly Altitude 2015
 
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
 
Bulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & CouchbaseBulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & Couchbase
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and Friends
 
Dropwizard and Groovy
Dropwizard and GroovyDropwizard and Groovy
Dropwizard and Groovy
 
Dropwizard Introduction
Dropwizard IntroductionDropwizard Introduction
Dropwizard Introduction
 
Service workers
Service workersService workers
Service workers
 
Forensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance InvestigationsForensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance Investigations
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
EWD 3 Training Course Part 14: Using Ajax for QEWD MessagesEWD 3 Training Course Part 14: Using Ajax for QEWD Messages
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
 
Play + scala + reactive mongo
Play + scala + reactive mongoPlay + scala + reactive mongo
Play + scala + reactive mongo
 
Service Worker - Reliability bits
Service Worker - Reliability bitsService Worker - Reliability bits
Service Worker - Reliability bits
 
Grails Launchpad - From Ground Zero to Orbit
Grails Launchpad - From Ground Zero to OrbitGrails Launchpad - From Ground Zero to Orbit
Grails Launchpad - From Ground Zero to Orbit
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and Java
 
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with Dropwizard
 

Similar to Serverless Java Kubernetes

Building serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platformBuilding serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platformLucio Grenzi
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Codemotion
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.xYiguang Hu
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsGary Yeh
 
Future Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NETFuture Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NETGianluca Carucci
 
"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "FDConf
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidenceJohn Congdon
 
Not Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsNot Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsKonrad Malawski
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationBen Hall
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCLFastly
 
Building Progressive Web Apps for Windows devices
Building Progressive Web Apps for Windows devicesBuilding Progressive Web Apps for Windows devices
Building Progressive Web Apps for Windows devicesWindows Developer
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsJack Franklin
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsFrancois Zaninotto
 

Similar to Serverless Java Kubernetes (20)

Building serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platformBuilding serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platform
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.x
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
 
Future Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NETFuture Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NET
 
"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
NodeJS
NodeJSNodeJS
NodeJS
 
Not Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsNot Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabs
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS Application
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
 
Building Progressive Web Apps for Windows devices
Building Progressive Web Apps for Windows devicesBuilding Progressive Web Apps for Windows devices
Building Progressive Web Apps for Windows devices
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 

Recently uploaded

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 

Recently uploaded (20)

Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 

Serverless Java Kubernetes

  • 1.
  • 2. Serverless Java on Kubernetes Krzysztof Sobkowiak (@ksobkowiak) https://blog.cdemi.io/what-is-serverless-architecture/ Wrocław, 01.03.2019 #TechTalkSE
  • 3. About me ● Capgemini ○ Senior Delivery Architect, Trainer ○ JEE & OSS solutions, system integration, cloud, microservices, devops ● Apache Software Foundation ○ Member ○ Apache ServiceMix Committer & PMC Chair (V.P. ServiceMix) ○ Contributor @ Apache Karaf, Apache CXF, Apache Camel, Apache ActiveMQ ● Co-organizer of #geekweekwro Views in this presentation are my personal views and do not necessarily reflect the views of Capgemini or The Apache Software Foundation.
  • 10. What is 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.” https://www.cncf.io/blog/2018/02/14/cncf-takes-first-step-towards-serverless-computing/
  • 11. What is serverless? “Serverless architectures are application designs that incorporate third-party “Backend as a Service” (BaaS) services, and/or that include custom code run in managed, ephemeral containers on a “Functions as a Service” (FaaS) platform.” https://martinfowler.com/articles/serverless.html
  • 12. Function as a Service (FaaS) ● Function ○ Small bits of code with a well defined job ○ Easy to understand and maintain ● As a service ○ The system takes care of provisioning, scaling, patching, … ○ Each function can scale independently fx
  • 15.
  • 16. FaaS Kubernetes & Java support
  • 18. Integrate with many popular services https://openwhisk.apache.org/
  • 20. How does it work? https://medium.com/openwhisk/uncovering-the-magic-how-serverless-platforms-really-work-3cb127b05f71
  • 21. OpenWhisk & Containers wsk action invoke docker run ≈
  • 22. OpenWhisk & Containers Start container docker run Initialize /init Run /run https://medium.com/openwhisk/squeezing-the-milliseconds-how-to-make-serverless-platforms-blazing-fast-aea0e9951bd0
  • 23. OpenWhisk & Containers cold Start container docker run Initialize /init Run /run https://medium.com/openwhisk/squeezing-the-milliseconds-how-to-make-serverless-platforms-blazing-fast-aea0e9951bd0
  • 24. OpenWhisk & Containers cold pre-warmed, paused Start container docker run Initialize /init Run /run https://medium.com/openwhisk/squeezing-the-milliseconds-how-to-make-serverless-platforms-blazing-fast-aea0e9951bd0
  • 25. OpenWhisk & Containers cold pre-warmed, paused hot Start container docker run Initialize /init Run /run https://medium.com/openwhisk/squeezing-the-milliseconds-how-to-make-serverless-platforms-blazing-fast-aea0e9951bd0
  • 26. OpenWhisk & Containers cold pre-warmed, paused hot Start container docker run Initialize /init Run /run fasterhttps://medium.com/openwhisk/squeezing-the-milliseconds-how-to-make-serverless-platforms-blazing-fast-aea0e9951bd0
  • 28. ● Basic unit of work ● A stateless, relatively short-running function ● Invoked as an event handler. ● Invoking an action generates an "activation id", used to retrieve results Action JSONJSON
  • 30. Action - JavaScript function main(params) { return { payload: 'Hello ' + params.body.text + ' from JavaScript action on OpenWhisk on OpenShift '}; }
  • 31. Creating an action To create an action, we need to we need to give it a name and configure it in OpenWhisk $ wsk -i action create msgaction msgaction.js
  • 32. Invoking an action Once it has a name, it can be invoked directly: $ wsk -i action invoke msgaction --param body '{"text":"Tech Talk SE"}' --result { "payload": "Hello Tech Talk SE from JavaScript action on OpenWhisk on OpenShift" } $ wsk -i activation get -l # see the details, logs
  • 33. Action - Python def main(params): return { "payload" : "Hello " + str(params["body"]["text"]) + " from Python action on OpenWhisk on OpenShift"}
  • 34. Updating an action $ wsk -i action update msgaction msgaction.py $ wsk -i action invoke msgaction --param body '{"text":"Tech Talk SE"}' --result { "payload": "Hello Tech Talk SE from Python action on OpenWhisk on OpenShift" }
  • 35. Creating an action packages: demo: actions: msgaction: function: msgaction.js $ wskdeploy -m manifest-msgaction.yml
  • 36. ● Wide choice of good tooling ● “Plain old Java” ● Ability to build complex applications ● Low latency/high performance ● Serverless JVM Blueprints for Serverless Java
  • 37. Action - Java (POF) public static JsonObject main(JsonObject params) { JsonObject response = new JsonObject(); response.addProperty("payload", "Hello " + params.getAsJsonObject("body").get("text").getAsString() + " from Java action on OpenWhisk on OpenShift " ); return response; }
  • 38. Action - Java $ wsk -i action update msgaction target/msgaction.jar --main com.example.FunctionMain $ wsk -i action invoke msgaction --param body '{"text":"Tech Talk SE"}' --result { "payload": "Hello Tech Talk SE from Java action on OpenWhisk on OpenShift" } $ mvn clean package
  • 39. Spring Cloud Functions (SCF) Spring Boot Spring Cloud Function Web Spring Cloud Function Webflux Spring Cloud Stream HTTP Message
  • 40. Serverless Platforms Adapters FaaS Provides Spring Cloud Function Adapter HTTP Message
  • 41. Spring Cloud Functions (SCF) @SpringBootApplication public class Application { @Bean public Function<Flux<String>, Flux<String>> uppercase() { return flux -> flux.map(value -> value.toUpperCase()); } public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
  • 42. ● Wide choice of good tooling → Maven, Gradle, IDE,... ● “Plain old Java” → POF ● Ability to build complex applications → SCF ● Low latency/high performance →pre-warmed containers, OpenJ9, CDS, AOT ● Serverless JVM → OpenJ9 Blueprints for Serverless Java
  • 43. Demo - Java Action bit.ly/faas-tutorial
  • 44. Serverless Microservices - web actions & api gateway ● Actions invoked via urls using HTTP verbs like GET, POST, PUT, … ● Automatic content detection via prefixing ● Api Gateway - proxy to Web Actions ○ HTTP method routing ○ client id/secrets ○ rate limiting ○ CORS https://github.com/rabbah/wsk-qr
  • 45. Web Actions & API Gateway $ wsk -i action create fibonacci fibonacci.js --web true $ WEB_URL=`wsk -i action get --url fibonacci | awk 'FNR==2{print $1}'` $ curl -k $WEB_URL.json?num=5 $ wsk -i api create /fibonacci get fibonacci $ curl -X GET ${API_URL}/api/${GENERATED_API_ID}/fibonacci?num=5
  • 46. API Gateway wsk api create -n "Book Club" /club /books/{isbn} get getBooks wsk api create /club /books get getBooks wsk api create /club /books post postBooks wsk api create /club /books/{isbn} put putBooks wsk api create /club /books/{isbn} delete deleteBooks
  • 47. Demo - Web Action
  • 48. Action Composition https://openwhisk.apache.org/ ● Pre-defined chain of actions ○ Sequences ● Determined dynamically ○ Conductors ○ Composer ● Output of previous step is input of the next one ● Only first function in Sequence can accept parameter
  • 49. Action Sequence $ wsk action create mySequence --sequence /whisk.system/utils/split,/whisk.system/utils/sort $ wsk action invoke --result mySequence --param payload "Java,Python,Swift,JavaScript,Ruby,C" --param separator ','
  • 50. Demo - Action Chaining
  • 51. Event Driven Capabilities ● Triggers are channels for events ● Triggers can be linked, via rules, to one or more actions ● Events could be ○ Another function ○ External event source called as Feed Provider ● Trigger can be registered to Event Provider via Feeds (Stream of Events) ○ Feed can be: ■ Polling ■ Webhook ■ Persistent Connection JSON
  • 52. Trigger & Rules $ wsk -i trigger create every-5-seconds --feed /whisk.system/alarms/alarm --param cron '*/5 * * * * *' --param maxTriggers 25 --param trigger_payload "{"name":"Tech Talk SE","place":"Wroclaw"}" $ wsk -i rule create invoke-periodically every-5-seconds /whisk.system/samples/greeting $ wsk -i activation poll
  • 53. Demo - Triggers & Rules
  • 55. Knative & OpenWhisk Kubernetes Foundational container scheduling and infrastructure management Cluster Management Capacity Management Network Management Consistent & repeatable deployment OpenWhisk Serverless abstractions (actions, triggers, rules, etc) & multi-tenancy Higher level abstractions (action, trigger, rule) API gateway & management CLI & dev tools Multi-tenancy High level control flow logic Throttles Web Actions Autoscaling Eventing Routing Code → Container conversion Serverless infrastructure building blocks & routing Knative https://www.ibm.com/blogs/cloud-computing/2018/07/24/ibm-cloud-google-knative-serverless/
  • 57. Credits Special thanks to all the people who made and released their awesome resources for free: ● Serverless Java: Challenges and Triumphs by David Delabassee ● Serverless Java on Kubernetes by Burr Sutter and Rafael Benevides ● Functions as a Service with Apache OpenWhisk and Openshift by Brendan McAdams ● Your Journey into the Serverless World by Kamesh Sampath