5. Their goal: pick the right runtime for each workload
CONTAINERS
EVENT-DRIVEN
FUNCTIONS
DATA SERVICESMICROSERVICES
Batches
MONOLITHIC
APPLICATIONS
IaaS
Container
Orchestrator
(CaaS)
Application
Platform
(PaaS)
Serverless
Functions
(FaaS)
6.
7.
8. Why Serverless?
8
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.
10. • 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
11. Spring Cloud Function
• FaaS Portable
• Run in Spring Boot
• REST, Tasks, or Streams
https://github.com/spring-cloud/spring-cloud-function
15. 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();
}
16. 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;
}
}
17. Spring Cloud Function (Web)
<dependency>
<groupId>org.springframework.cloud<groupId>
<artifactId>spring-cloud-function-web</artifactId>
<version>1.0.0.M3</version>
</dependency>
18. Spring Cloud Function (Message)
<dependency>
<groupId>org.springframework.cloud<groupId>
<artifactId>spring-cloud-function-message</
artifactId>
<version>1.0.0.M3</version>
</dependency>
19. 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);
}
}