close

Serverless

Serverless applications take advantage of modern cloud computing capabilities and abstractions to let you focus on logic rather than on infrastructure. In a serverless environment, you can concentrate on writing application code while the underlying platform takes care of scaling, runtimes, resource allocation, security, and other “server” specifics.

What is serverless?

Serverless workloads are “event-driven workloads that aren’t concerned with aspects normally handled by server infrastructure.” Concerns like “how many instances to run” and “what operating system to use” are all managed by a Function as a Service platform (or FaaS), leaving developers free to focus on business logic.

Serverless characteristics?

Serverless applications have a number of specific characteristics, including:

  • Event-driven code execution with triggers
  • Platform handles all the starting, stopping, and scaling chores
  • Scales to zero, with low to no cost when idle
  • Stateless

Serverless vs Traditional Stack

Function as a Service (FaaS) and Legacy diagram

Function as a Service (FaaS)

  • Event-driven execution.
  • Developers delegate all server-specific tasks to the FaaS platform.
  • Developers only write business logic that is invoked by the platform, allowing for a more resilient requirement evolution as business needs change.

Traditional applications

  • Must maintain server infrastructure (installing, configuring, patching, upgrading, etc.).
  • Infrastructure scales in ways that might not be dynamic enough for the workload (wasting resources).
  • Developers write integration code to deal with messaging platforms, HTTP request/responses, etc.

Why Spring and Serverless?

The Spring portfolio provides a robust collection of functionality for use within serverless applications. Whether accessing data with Spring Data, using the enterprise integration patterns with Spring Integration, or using the latest in reactive programming with Spring Framework and Project Reactor, Spring lets developers be productive in a serverless environment from day one.

Spring also helps your functions avoid vendor lock-in. The adapters provided by Spring Cloud Function let you decouple from vendor-specific APIs when running your code on their platform.

In detail: Spring Cloud Function

Spring Cloud Function provides capabilities that lets Spring developers take advantage of serverless or FaaS platforms.

The java.util.function package from core Java serves as the foundation of the programming model used by Spring Cloud Function. In a nutshell, Spring Cloud Function provides:

  • Choice of programming styles: reactive, imperative, or hybrid.
  • Function composition and adaptation (such as composing imperative functions with reactive).
  • Support for reactive function with multiple inputs and outputs to let functions handle merging, joining, and other complex streaming operations.
  • Transparent type conversion of inputs and outputs.
  • Packaging functions for deployments, specific to the target platform (such as Project Riff, AWS Lambda, and more; see below).
  • Functions with flexible signatures (POJO functions) - “if it looks like a function, it’s a function”
  • All other benefits of Spring's idioms and programming model.

Spring Cloud Function provides adaptors so that you can run your functions on the most common FaaS services including Amazon Lambda, Apache OpenWhisk, Microsoft Azure, and Project Riff.

Ready to get started?