Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Serverless Spring

SpringOne Platform 2017
Mark Fisher, Pivotal

This live coding session will introduce Spring Cloud Function, from the basic programming model all the way to multicloud deployments. Along the way, we'll explore the current state of Java across Function-as-a-Service providers and demonstrate what role Spring can play in the Serverless world.

  • Login to see the comments

Serverless Spring

  1. 1. Serverless Spring cloud.spring.io/spring-cloud-function github.com/projectriff/riff Dave Syer @david_syer Mark Fisher @m_f_ 1
  2. 2. Why Serverless? 3 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. 3. Use Cases 4 Large Scale Data • Bulk Processing • IoT streams • Log ingestion • Machine Learning • Stateful Stream Processing Web Events • Website back-end services like form post handlers, authentication, tracking and logging. • APIs to back-end data services for mobile and web apps e.g GraphQL • Webhook handlers • CI/CD automation • Chat integrations • Digital assistant services e.g. Alexa skills Event-based Integration • Scheduled tasks, ETL • File processing e.g. images and videos • Security scanning • Complex Event Processing and Change Data Capture • Monitoring, notifications and alerting • Custom auth e.g. via API Gateway CNCF Serverless Working Group
  4. 4. 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
  5. 5. Java Util Function
  6. 6. Spring Cloud Function
  7. 7. Spring Cloud Function • FaaS Portable • Run in Spring Boot • REST, Tasks, or Streams https://github.com/spring-cloud/spring-cloud-function
  8. 8. Project Reactor
  9. 9. Spring Cloud Function
  10. 10. 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? 11 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
  11. 11. 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/ 12 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
  12. 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/ functions are packaged as containers 13 Function Invoker Function Code Container Base Image Function Layer Container Registry
  13. 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/ sidecars connect functions with event brokers 14 Function Pod Function ContainerSidecar Container Event Broker broker-specific API binder dispatcher invoker function HTTP gRPC stdio
  14. 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/ 15 functions and topics are Kubernetes resources Function Controller Function YAML - name - input / output topics - artifact / params Topic YAML - name - params KafkaHttp Gateway Topic Controller Sc Fn Pod Sc Fn Pod Sc Fn Pod k8s API
  15. 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/ functions scale with events riff function controller ★ interacts with K8s API ★ scales functions 0-1 and 1-N ★ monitors event-lag in Kafka 16 Event Broker f(x) f(x) f(x) k8s API
  16. 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/ 17 public class VoteStreamProcessor implements Function<Flux<String>, Flux<Map<String, Object>>> { public Flux<Map<String, Object>> apply(Flux<String> words) { return words.window(Duration.ofSeconds(60), Duration.ofSeconds(2)) .concatMap(w -> w.collect(VoteAggregate::new, VoteAggregate::sum) .map(VoteAggregate::windowMap), Integer.MAX_VALUE); } } functions can process streams using Reactor
  17. 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/ 18 helm init helm repo add riffrepo https://riff.charts.storage.googleapps.com helm repo update helm install riffrepo/riff --name demo installing riff via helm helm install riffrepo/riff --name demo --set create.rbac=true --set httpGateway.service.type=NodePort
  18. 18. 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/ demo 19 Kafka f(x) f(x) vote-counter vote-stream processor votes topic redis
  19. 19. Learn More. Stay Connected. cloud.spring.io/spring-cloud-function github.com/projectriff/riff 20 #springone@s1p

×