Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Spring Cloud Function & Project Riff

Spring Cloud Function & Project Riff

Anwar Chirakkattil

April 24, 2018
Tweet

Other Decks in Technology

Transcript

  1. 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)
  2. 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.
  3. 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
  4. • 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
  5. Spring Cloud Function • FaaS Portable • Run in Spring

    Boot • REST, Tasks, or Streams https://github.com/spring-cloud/spring-cloud-function
  6. HTTP Message Functions Spring Cloud Function Adapter Faas Provider Currently

    • AWS lambda • Azure Function • Apache OpenWhisk are supported
  7. Java Util Function public interface Function<T, R> { R apply(T

    t); } public interface Consumer<T> { void accept(T t); } public interface Supplier<T> { T get(); }
  8. Write a function package functions; import java.util.function.Function; public class Greeter

    implements Function<String, String> { public String apply(String name) { return "Hello " + name; } }
  9. 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); } }
  10. Spring Cloud Function @SpringBootApplication @FunctionScan public class App { public

    static void main(String[] args) { SpringApplication.run(App.class, args); } }
  11. Spring Cloud Function (Web) $ curl localhost:8080/greeter \ -w '\n'

    \ -H "Content-Type: text/plain" \ -d "MSUG" Hello MSUG
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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