Serverless Spring
-
Upload
pivotal -
Category
Technology
-
view
105 -
download
0
Transcript of Serverless Spring
![Page 1: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/1.jpg)
Serverless Springcloud.spring.io/spring-cloud-functiongithub.com/projectriff/riff
Dave Syer @david_syerMark Fisher @m_f_
1
![Page 2: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/2.jpg)
![Page 3: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/3.jpg)
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.
![Page 4: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/4.jpg)
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
![Page 5: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/5.jpg)
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
![Page 6: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/6.jpg)
Java Util Function
![Page 7: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/7.jpg)
Spring Cloud Function
![Page 8: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/8.jpg)
Spring Cloud Function
• FaaS Portable • Run in Spring Boot• REST, Tasks, or Streams
https://github.com/spring-cloud/spring-cloud-function
![Page 9: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/9.jpg)
Project Reactor
![Page 10: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/10.jpg)
Spring Cloud Function
![Page 11: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/11.jpg)
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
![Page 12: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/12.jpg)
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
![Page 13: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/13.jpg)
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
![Page 14: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/14.jpg)
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
![Page 15: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/15.jpg)
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
![Page 16: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/16.jpg)
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
![Page 17: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/17.jpg)
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
![Page 18: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/18.jpg)
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
![Page 19: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/19.jpg)
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
![Page 20: Serverless Spring](https://reader035.fdocuments.net/reader035/viewer/2022062306/5a64bfe57f8b9a76038b4821/html5/thumbnails/20.jpg)
Learn More. Stay Connected.
cloud.spring.io/spring-cloud-function
github.com/projectriff/riff
20
#springone@s1p