Implementing FaaS with Spring Cloud Functions

Under the umbrella of Spring projects, you will find the Spring Cloud Function project (https://cloud.spring.io/spring-cloud-function/), which is designed to implement applications using a serverless architecture model.

Using Spring Cloud Function, we can code functions that can be launched on different cloud providers that support FaaS. There's no need to learn something new from scratch, because all of the core concepts and main features of Spring Framework, such as autoconfiguration, dependency injection, and built-in metrics, are applied in the same way.

Once a function has been coded, it can be deployed as a web endpoint, a stream processor, or simple tasks that are triggered by certain events or via a scheduler.

Looking at an example of an SPA, we can implement an application using third-party services, the existing REST API, and custom functions. The following diagram illustrates how an application can be created by using all of the previously mentioned options:

Integrating FaaS in applications

Let's review how the components in the preceding diagram work:

  • Authentication is provided by a third-party service
  • The application uses the business logic that resides in the REST API
  • A custom function can be used as a part of the SPA

The following diagram illustrates how a function works:

Function as a service

Let's review each part of the diagram:

  • Functions provide a way to use an event-driven programming model.
  • We can scale infinitely, in a way that is transparent to developers. This scale will be handled by the platform that we use to deploy the function.
  • Finally, we only pay for the time and resources consumed by the functions during their execution.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.166.149