SlideShare a Scribd company logo
1 of 30
Download to read offline
Serverless Spring@david_syer, 2018
Serverless Spring http://localhost:4000/decks/serverless-spring.html
1 of 30 30/01/2019, 10:04
Agenda
Serverless and functions
Servless platforms, including Riff
Spring Cloud Function
http://github.com/spring-cloud/spring-cloud-function
http://projectreactor.io/
Serverless Spring http://localhost:4000/decks/serverless-spring.html
2 of 30 30/01/2019, 10:04
Serverless
Event driven
Dynamic resource utilization, "scale to zero"
Billing per message
Focus on business logic
Easy integration with platform services
Serverless Spring http://localhost:4000/decks/serverless-spring.html
3 of 30 30/01/2019, 10:04
Serverless Use Cases
Web hooks
Background jobs
Glue code (hands-free integration)
CNCF WG Whitepaper
Serverless Spring http://localhost:4000/decks/serverless-spring.html
4 of 30 30/01/2019, 10:04
No Code is an Island
Credit: Yan Cui, https://theburningmonk.com
Serverless Spring http://localhost:4000/decks/serverless-spring.html
5 of 30 30/01/2019, 10:04
Service Block
Serverless Spring http://localhost:4000/decks/serverless-spring.html
6 of 30 30/01/2019, 10:04
Amazon Lambda
Serverless Spring http://localhost:4000/decks/serverless-spring.html
7 of 30 30/01/2019, 10:04
Serverless Spring http://localhost:4000/decks/serverless-spring.html
8 of 30 30/01/2019, 10:04
Google Cloud Function
Serverless Spring http://localhost:4000/decks/serverless-spring.html
9 of 30 30/01/2019, 10:04
Serverless Spring http://localhost:4000/decks/serverless-spring.html
10 of 30 30/01/2019, 10:04
Microsoft Azure Functions
Serverless Spring http://localhost:4000/decks/serverless-spring.html
11 of 30 30/01/2019, 10:04
Serverless Spring http://localhost:4000/decks/serverless-spring.html
12 of 30 30/01/2019, 10:04
Alibaba Function Compute
Serverless Spring http://localhost:4000/decks/serverless-spring.html
13 of 30 30/01/2019, 10:04
Serverless Spring http://localhost:4000/decks/serverless-spring.html
14 of 30 30/01/2019, 10:04
Riff
Serverless Spring http://localhost:4000/decks/serverless-spring.html
15 of 30 30/01/2019, 10:04
Serverless Spring http://localhost:4000/decks/serverless-spring.html
16 of 30 30/01/2019, 10:04
Serverless Providers
(J) Amazon Lambda
Google Cloud Functions
(J) Azure Function
(J) Alibaba
(J) Riff https://projectriff.io and PFS
(J) IBM OpenWhisk
(J) Oracle Fn
OpenFaaS
Fission
Kubeless
โ€ฆ
(J) = native Java support
Others can run Java, e.g. via custom container or node JRE launcher.
Serverless Spring http://localhost:4000/decks/serverless-spring.html
17 of 30 30/01/2019, 10:04
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();
}
Serverless Spring http://localhost:4000/decks/serverless-spring.html
18 of 30 30/01/2019, 10:04
Spring Cloud Function
@SpringBootApplication
public class Application {
@Bean
public Function<String, String> uppercase() {
return value -> value.toUpperCase();
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Serverless Spring http://localhost:4000/decks/serverless-spring.html
19 of 30 30/01/2019, 10:04
Plain Old Functions
package functions;
public class Uppercase implements Function<String, String> {
String apply(String input) {
return input.toUpperCase();
}
}
Serverless Spring http://localhost:4000/decks/serverless-spring.html
20 of 30 30/01/2019, 10:04
AWS Cold Starts
Lambda throttles CPU resources when memory is constrained
โ€ฆ also billing is proportional to memory usage
โ€ฆ itโ€™s not that simple
Serverless Spring http://localhost:4000/decks/serverless-spring.html
21 of 30 30/01/2019, 10:04
Spring Cloud Function
All the benefits of serverless, but with full access to Spring (dependency injection, integrations,
autoconfiguration) and build tools (testing, continuous delivery, run locally)
For Spring devs: a smaller, more familiar step than using FaaS APIs and UIs natively
For Functionistas: no need to know anything about Spring
Decouple lifecycle of business logic from runtime platform. Run the same code as a web endpoint,
a stream processor, or a task
Uniform programming model across serverless providers, and also able to run standalone
(locally or in a PaaS)
Serverless Spring http://localhost:4000/decks/serverless-spring.html
22 of 30 30/01/2019, 10:04
Project Reactor
public abstract class Flux<T> implements Publisher<T> {
...
}
public abstract class Mono<T> implements Publisher<T> {
...
}
Serverless Spring http://localhost:4000/decks/serverless-spring.html
23 of 30 30/01/2019, 10:04
Spring Cloud Function
@SpringBootApplication
public class Application {
@Bean
public Function<Flux<String>, Flux<String>> uppercase() {
return flux -> flux
.filter(this::isNotRude)
.map(String::toUpperCase);
}
boolean isNotRude(String word) {
...
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Serverless Spring http://localhost:4000/decks/serverless-spring.html
24 of 30 30/01/2019, 10:04
Spring Cloud Function Adapter
Serverless Spring http://localhost:4000/decks/serverless-spring.html
25 of 30 30/01/2019, 10:04
Serverless Spring http://localhost:4000/decks/serverless-spring.html
26 of 30 30/01/2019, 10:04
Spring Cloud Function
Programming model: @Beans of type Function, Consumer and Supplier, with Flux,
Mono, Publisher
1.
Component scan for functions (e.g. execute jar with no dependency on Spring at all)2.
Compile strings which are Java function bodies3.
Bind and invoke from an isolated classloader (JVM packing, platform)4.
Adapters for Spring MVC, Spring Cloud Stream, AWS Lambda, Azure, Riff and other
"serverless" service providers
5.
Serverless Spring http://localhost:4000/decks/serverless-spring.html
27 of 30 30/01/2019, 10:04
Learnings
Spring is not slow or "heavy" on its own, classes loaded is important1.
AWS Lambda containers are slow, Azure even more so2.
Functional bean definitions rule for fast startup3.
Functions are glue code anyway - not latency sensitive4.
Scale to Zero5.
Platform services and integration spaghetti6.
Serverless Spring http://localhost:4000/decks/serverless-spring.html
28 of 30 30/01/2019, 10:04
Links
Spring Cloud Function: https://github.com/spring-cloud/spring-cloud-function
Riff: https://github.com/projectriff/riff
Spring Boot Thin Launcher: https://github.com/dsyer/spring-boot-thin-launcher
Spring Initializr: http://start.spring.io
Spring Cloud: http://cloud.spring.io
Reactor: http://projectreactor.io
Serverless Spring http://localhost:4000/decks/serverless-spring.html
29 of 30 30/01/2019, 10:04
โ† โ†’
1 / 23
Go to Slide: Go
Serverless Spring http://localhost:4000/decks/serverless-spring.html
30 of 30 30/01/2019, 10:04

More Related Content

Similar to Serverless Spring - Dave Syer

Spring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugSpring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsug
Toshiaki Maki
ย 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites
oazabir
ย 

Similar to Serverless Spring - Dave Syer (20)

SpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSASpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSA
ย 
Microservices with kubernetes @190316
Microservices with kubernetes @190316Microservices with kubernetes @190316
Microservices with kubernetes @190316
ย 
Serverless Spring by Stephane Maldini
Serverless Spring by Stephane MaldiniServerless Spring by Stephane Maldini
Serverless Spring by Stephane Maldini
ย 
Spring on PAS - Fabio Marinelli
Spring on PAS - Fabio MarinelliSpring on PAS - Fabio Marinelli
Spring on PAS - Fabio Marinelli
ย 
Spring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugSpring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsug
ย 
Microservices with Spring and Cloud Foundry
Microservices with Spring and Cloud FoundryMicroservices with Spring and Cloud Foundry
Microservices with Spring and Cloud Foundry
ย 
Microservices with Spring and Cloud Foundry
Microservices with Spring and Cloud FoundryMicroservices with Spring and Cloud Foundry
Microservices with Spring and Cloud Foundry
ย 
DevOpsDaysRiga 2018: Serhat Can - The Rocky Path to Migrating Production Appl...
DevOpsDaysRiga 2018: Serhat Can - The Rocky Path to Migrating Production Appl...DevOpsDaysRiga 2018: Serhat Can - The Rocky Path to Migrating Production Appl...
DevOpsDaysRiga 2018: Serhat Can - The Rocky Path to Migrating Production Appl...
ย 
Active object of Symbian in the lights of client server architecture
Active object of Symbian in the lights of client server architectureActive object of Symbian in the lights of client server architecture
Active object of Symbian in the lights of client server architecture
ย 
Grafana and AWS - Implementation and Usage
Grafana and AWS - Implementation and UsageGrafana and AWS - Implementation and Usage
Grafana and AWS - Implementation and Usage
ย 
UDP Report
UDP ReportUDP Report
UDP Report
ย 
Getting started with AWS IoT Core - SVC306 - New York AWS Summit
Getting started with AWS IoT Core - SVC306 - New York AWS SummitGetting started with AWS IoT Core - SVC306 - New York AWS Summit
Getting started with AWS IoT Core - SVC306 - New York AWS Summit
ย 
CloudStack Metering - Working with Usage Data #CCCNA14
CloudStack Metering - Working with Usage Data #CCCNA14CloudStack Metering - Working with Usage Data #CCCNA14
CloudStack Metering - Working with Usage Data #CCCNA14
ย 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites
ย 
Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluรจgnes
 Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluรจgnes Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluรจgnes
Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluรจgnes
ย 
Microservices with Netflix OSS and Spring Cloud
Microservices with Netflix OSS and Spring CloudMicroservices with Netflix OSS and Spring Cloud
Microservices with Netflix OSS and Spring Cloud
ย 
Lambda Architecture Using SQL
Lambda Architecture Using SQLLambda Architecture Using SQL
Lambda Architecture Using SQL
ย 
Running Serverless at The Edge (CTD302) - AWS re:Invent 2018
Running Serverless at The Edge (CTD302) - AWS re:Invent 2018Running Serverless at The Edge (CTD302) - AWS re:Invent 2018
Running Serverless at The Edge (CTD302) - AWS re:Invent 2018
ย 
Building Event-Driven (Micro) Services with Apache Kafka
Building Event-Driven (Micro) Services with Apache KafkaBuilding Event-Driven (Micro) Services with Apache Kafka
Building Event-Driven (Micro) Services with Apache Kafka
ย 
Microservices with .Net - NDC Sydney, 2016
Microservices with .Net - NDC Sydney, 2016Microservices with .Net - NDC Sydney, 2016
Microservices with .Net - NDC Sydney, 2016
ย 

More from VMware Tanzu

More from VMware Tanzu (20)

What AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About ItWhat AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About It
ย 
Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023
ย 
Enhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at ScaleEnhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at Scale
ย 
Spring Update | July 2023
Spring Update | July 2023Spring Update | July 2023
Spring Update | July 2023
ย 
Platforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a ProductPlatforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a Product
ย 
Building Cloud Ready Apps
Building Cloud Ready AppsBuilding Cloud Ready Apps
Building Cloud Ready Apps
ย 
Spring Boot 3 And Beyond
Spring Boot 3 And BeyondSpring Boot 3 And Beyond
Spring Boot 3 And Beyond
ย 
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdfSpring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
ย 
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
ย 
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
ย 
tanzu_developer_connect.pptx
tanzu_developer_connect.pptxtanzu_developer_connect.pptx
tanzu_developer_connect.pptx
ย 
Tanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - FrenchTanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - French
ย 
Tanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - EnglishTanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - English
ย 
Virtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - EnglishVirtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - English
ย 
Tanzu Developer Connect - French
Tanzu Developer Connect - FrenchTanzu Developer Connect - French
Tanzu Developer Connect - French
ย 
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
ย 
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring BootSpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
ย 
SpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software EngineerSpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software Engineer
ย 
SpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs PracticeSpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs Practice
ย 
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense SolutionsSpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
ย 

Recently uploaded

CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธ
anilsa9823
ย 
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
ย 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
ย 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
bodapatigopi8531
ย 

Recently uploaded (20)

CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธ
ย 
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
ย 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
ย 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
ย 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
ย 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
ย 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
ย 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
ย 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
ย 
Vip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS LiveVip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS Live
ย 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
ย 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
ย 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
ย 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
ย 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
ย 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
ย 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
ย 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
ย 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
ย 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
ย 

Serverless Spring - Dave Syer

  • 1. Serverless Spring@david_syer, 2018 Serverless Spring http://localhost:4000/decks/serverless-spring.html 1 of 30 30/01/2019, 10:04
  • 2. Agenda Serverless and functions Servless platforms, including Riff Spring Cloud Function http://github.com/spring-cloud/spring-cloud-function http://projectreactor.io/ Serverless Spring http://localhost:4000/decks/serverless-spring.html 2 of 30 30/01/2019, 10:04
  • 3. Serverless Event driven Dynamic resource utilization, "scale to zero" Billing per message Focus on business logic Easy integration with platform services Serverless Spring http://localhost:4000/decks/serverless-spring.html 3 of 30 30/01/2019, 10:04
  • 4. Serverless Use Cases Web hooks Background jobs Glue code (hands-free integration) CNCF WG Whitepaper Serverless Spring http://localhost:4000/decks/serverless-spring.html 4 of 30 30/01/2019, 10:04
  • 5. No Code is an Island Credit: Yan Cui, https://theburningmonk.com Serverless Spring http://localhost:4000/decks/serverless-spring.html 5 of 30 30/01/2019, 10:04
  • 6. Service Block Serverless Spring http://localhost:4000/decks/serverless-spring.html 6 of 30 30/01/2019, 10:04
  • 7. Amazon Lambda Serverless Spring http://localhost:4000/decks/serverless-spring.html 7 of 30 30/01/2019, 10:04
  • 9. Google Cloud Function Serverless Spring http://localhost:4000/decks/serverless-spring.html 9 of 30 30/01/2019, 10:04
  • 11. Microsoft Azure Functions Serverless Spring http://localhost:4000/decks/serverless-spring.html 11 of 30 30/01/2019, 10:04
  • 13. Alibaba Function Compute Serverless Spring http://localhost:4000/decks/serverless-spring.html 13 of 30 30/01/2019, 10:04
  • 17. Serverless Providers (J) Amazon Lambda Google Cloud Functions (J) Azure Function (J) Alibaba (J) Riff https://projectriff.io and PFS (J) IBM OpenWhisk (J) Oracle Fn OpenFaaS Fission Kubeless โ€ฆ (J) = native Java support Others can run Java, e.g. via custom container or node JRE launcher. Serverless Spring http://localhost:4000/decks/serverless-spring.html 17 of 30 30/01/2019, 10:04
  • 18. 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(); } Serverless Spring http://localhost:4000/decks/serverless-spring.html 18 of 30 30/01/2019, 10:04
  • 19. Spring Cloud Function @SpringBootApplication public class Application { @Bean public Function<String, String> uppercase() { return value -> value.toUpperCase(); } public static void main(String[] args) { SpringApplication.run(Application.class, args); } } Serverless Spring http://localhost:4000/decks/serverless-spring.html 19 of 30 30/01/2019, 10:04
  • 20. Plain Old Functions package functions; public class Uppercase implements Function<String, String> { String apply(String input) { return input.toUpperCase(); } } Serverless Spring http://localhost:4000/decks/serverless-spring.html 20 of 30 30/01/2019, 10:04
  • 21. AWS Cold Starts Lambda throttles CPU resources when memory is constrained โ€ฆ also billing is proportional to memory usage โ€ฆ itโ€™s not that simple Serverless Spring http://localhost:4000/decks/serverless-spring.html 21 of 30 30/01/2019, 10:04
  • 22. Spring Cloud Function All the benefits of serverless, but with full access to Spring (dependency injection, integrations, autoconfiguration) and build tools (testing, continuous delivery, run locally) For Spring devs: a smaller, more familiar step than using FaaS APIs and UIs natively For Functionistas: no need to know anything about Spring Decouple lifecycle of business logic from runtime platform. Run the same code as a web endpoint, a stream processor, or a task Uniform programming model across serverless providers, and also able to run standalone (locally or in a PaaS) Serverless Spring http://localhost:4000/decks/serverless-spring.html 22 of 30 30/01/2019, 10:04
  • 23. Project Reactor public abstract class Flux<T> implements Publisher<T> { ... } public abstract class Mono<T> implements Publisher<T> { ... } Serverless Spring http://localhost:4000/decks/serverless-spring.html 23 of 30 30/01/2019, 10:04
  • 24. Spring Cloud Function @SpringBootApplication public class Application { @Bean public Function<Flux<String>, Flux<String>> uppercase() { return flux -> flux .filter(this::isNotRude) .map(String::toUpperCase); } boolean isNotRude(String word) { ... } public static void main(String[] args) { SpringApplication.run(Application.class, args); } } Serverless Spring http://localhost:4000/decks/serverless-spring.html 24 of 30 30/01/2019, 10:04
  • 25. Spring Cloud Function Adapter Serverless Spring http://localhost:4000/decks/serverless-spring.html 25 of 30 30/01/2019, 10:04
  • 27. Spring Cloud Function Programming model: @Beans of type Function, Consumer and Supplier, with Flux, Mono, Publisher 1. Component scan for functions (e.g. execute jar with no dependency on Spring at all)2. Compile strings which are Java function bodies3. Bind and invoke from an isolated classloader (JVM packing, platform)4. Adapters for Spring MVC, Spring Cloud Stream, AWS Lambda, Azure, Riff and other "serverless" service providers 5. Serverless Spring http://localhost:4000/decks/serverless-spring.html 27 of 30 30/01/2019, 10:04
  • 28. Learnings Spring is not slow or "heavy" on its own, classes loaded is important1. AWS Lambda containers are slow, Azure even more so2. Functional bean definitions rule for fast startup3. Functions are glue code anyway - not latency sensitive4. Scale to Zero5. Platform services and integration spaghetti6. Serverless Spring http://localhost:4000/decks/serverless-spring.html 28 of 30 30/01/2019, 10:04
  • 29. Links Spring Cloud Function: https://github.com/spring-cloud/spring-cloud-function Riff: https://github.com/projectriff/riff Spring Boot Thin Launcher: https://github.com/dsyer/spring-boot-thin-launcher Spring Initializr: http://start.spring.io Spring Cloud: http://cloud.spring.io Reactor: http://projectreactor.io Serverless Spring http://localhost:4000/decks/serverless-spring.html 29 of 30 30/01/2019, 10:04
  • 30. โ† โ†’ 1 / 23 Go to Slide: Go Serverless Spring http://localhost:4000/decks/serverless-spring.html 30 of 30 30/01/2019, 10:04