serverless spring
TRANSCRIPT
Serverless Springcloud.spring.io/spring-cloud-functiongithub.com/projectriff/riff
Dave Syer @david_syerMark Fisher @m_f_
1
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.
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
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
Java Util Function
Spring Cloud Function
Spring Cloud Function
• FaaS Portable • Run in Spring Boot• REST, Tasks, or Streams
https://github.com/spring-cloud/spring-cloud-function
Project Reactor
Spring Cloud Function
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
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
˥
ImmediateInstant-on
ConsistentImmutableContainers
EfficientScale 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
ICEWant serverless?... pick 2
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
FunctionInvoker
Function Code
Container Base Image
Function Layer
ContainerRegistry
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
EventBroker
broker-specific API
binder dispatcher invoker function
HTTPgRPCstdio
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
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
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
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
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-streamprocessor
votestopic
redis
Learn More. Stay Connected.
cloud.spring.io/spring-cloud-function
github.com/projectriff/riff
20
#springone@s1p