Slide 1

Slide 1 text

Serverless Spring & Project riff Minneapolis Spring User Group Anwar Chirakkattil - Pivotal @anwarchk

Slide 2

Slide 2 text

CONTAINERS EVENT-DRIVEN FUNCTIONS DATA SERVICES MICROSERVICES Batches MONOLITHIC APPLICATIONS Organizations have many ways to package and run their workloads in the cloud

Slide 3

Slide 3 text

Their goal: pick the right runtime for each workload CONTAINERS EVENT-DRIVEN FUNCTIONS DATA SERVICES MICROSERVICES Batches MONOLITHIC APPLICATIONS IaaS Container Orchestrator (CaaS) Application
 Platform (PaaS) Serverless
 Functions (FaaS)

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Why Serverless? 5 1. Narrowly-scoped units of code, and the simplicity of built-in event integration, contribute to software development efficiencies. 2. Functions which don’t consume resources when idle can provide significant resource efficiencies. 3. Applying Serverless to distributed computing brings operational efficiencies based on automated event-based scheduling and self- scaling.

Slide 6

Slide 6 text

Who is offering FaaS? Hosted • AWS Lambda • Azure Functions • Google Cloud Functions On-Prem / OSS • riff (https://github.com/projectriff ) • Oracle fn • OpenWhisk • Fission • Kubeless • OpenFaaS

Slide 7

Slide 7 text

• Focus on the implementation of business logic via functions • Decouple the business logic from any specific runtime (HTTP, Message) • Support a uniform programming model across FaaS providers • Run standalone (locally or in a PaaS) • Enable Spring Boot features on FaaS providers Spring Cloud Function

Slide 8

Slide 8 text

Spring Cloud Function • FaaS Portable • Run in Spring Boot • REST, Tasks, or Streams https://github.com/spring-cloud/spring-cloud-function

Slide 9

Slide 9 text

HTTP Message Functions Spring Cloud Function Web Spring Cloud Function Message Spring Boot

Slide 10

Slide 10 text

HTTP Message Functions Spring Cloud Function Adapter Faas Provider Currently • AWS lambda • Azure Function • Apache OpenWhisk are supported

Slide 11

Slide 11 text

Java Util Function public interface Function { R apply(T t); } public interface Consumer { void accept(T t); } public interface Supplier { T get(); }

Slide 12

Slide 12 text

Write a function package functions; import java.util.function.Function; public class Greeter implements Function { public String apply(String name) { return "Hello " + name; } }

Slide 13

Slide 13 text

Spring Cloud Function (Web) org.springframework.cloud spring-cloud-function-web 1.0.0.M6

Slide 14

Slide 14 text

Spring Cloud Function (Message) org.springframework.cloud spring-cloud-function-message 1.0.0.M6

Slide 15

Slide 15 text

Spring Cloud Function @SpringBootApplication public class App { @Bean public Greeter greeter() { return new Greeter(); } public static void main(String[] args) { SpringApplication.run(App.class, args); } }

Slide 16

Slide 16 text

Spring Cloud Function @SpringBootApplication @FunctionScan public class App { public static void main(String[] args) { SpringApplication.run(App.class, args); } }

Slide 17

Slide 17 text

Spring Cloud Function (Web) $ curl localhost:8080/greeter \ -w '\n' \ -H "Content-Type: text/plain" \ -d "MSUG" Hello MSUG

Slide 18

Slide 18 text

DEMO

Slide 19

Slide 19 text

Project riff https://projectriff.io/

Slide 20

Slide 20 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ what is riff? 20 riff provides developers with a service for executing Functions in response to Events. Features ★ event streaming ★ polyglot ★ Kubernetes-native Events f(x) f(x) f(x) Functions f(x) riff

Slide 21

Slide 21 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ functions are packaged as containers 21 Function Invoker Function Code Container Base Image Function Layer Container Registry Currently • Java • Node • Bash • Python are supported

Slide 22

Slide 22 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ sidecars connect functions with event brokers 22 Function Pod Function Container Sidecar Container Event
 Broker broker-specific API binder dispatcher invoker function HTTP gRPC stdio pipes

Slide 23

Slide 23 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 23 functions and topics are Kubernetes resources Function Controller Function YAML - name - input / output topics - artifact / params Topic YAML - name - params Kafka Http Gateway Topic Controller Sc Fn Pod Sc Fn Pod Sc Fn Pod k8s API

Slide 24

Slide 24 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ functions scale with events riff function controller ★ interacts with K8s API ★ scales functions 0-1 and 1-N ★ monitors event-lag in Kafka 24 Function Controller Event Broker f(x) f(x) f(x) k8s API

Slide 25

Slide 25 text

Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 25 Immediate Instant-on Consistent Immutable Containers Efficient Scale to Zero Choice of Compromises: • Launch Function containers on demand
 => Slow start • Inject Function code into running containers
 => Breaks container immutability • Keep Function containers running
 => Pay for idle resources ICE
 Want serverless?... pick 2

Slide 26

Slide 26 text

DEMO

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Resources - https://projectriff.io/ - https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-samples https://github.com/projectriff-samples - https://github.com/BrianMMcClain/riff-demos - https://content.pivotal.io/blog/building-functions-with-riff - https://github.com/anwarchk/spring-cloud-function-azure

Slide 29

Slide 29 text

Thank you !