Skip to content

OpenFaas for Serverless

The Serverless era

Faas (Function as a Service) is a modern methodology that split the service layer in a set of functions that are available ONLY when necessary. This approach allow to design the serverless architecture that are becoming very popular in the cloud. When an user start a transaction to buy a Coca cola at the cash a new instance of the payment function service is created and it will be destroyed after the end of the transaction. This allow to save resource, save money and test it in isolation mode using containers. The basic concept is: "I will pay the cloud provider only when the function is invoked by a client". If no one are using my function I don't need to pay a flat rent, consuming resources and money for something that now is not necessary.

Function layers that split microservices

OpenFaaS as a serverless solution

Basically doesn't matter if there are some servers and where are they located. The developer should only define functions. The container orchestrator (Kubernetes for example) will take care of where the function should be deployed and how much hardware resources it needs. So OpenFaaS is simply a way to put function in Kubernetes defined as small containers that the orchestrator needs to manage.

OpenFaaS architecture

Some notes about Faas architecture:

  • API gateway is the place where new functions are defined. Plus: user can obtain functions from cloud repository or push new ones in the same way as for docker store!
  • A watchdog component is defined in all docker containers that host the function and it take care about all the operations necessary to deploy the container, pick the necessary hw resources and so on
  • Prometheus collects stats about our stack with a dashboard that reports all the useful information (number of times that the function is invoked, number of instances and so on)

OpenFaaS architecture

Implement FaaS with Minikube

Minikube is a Kubernetes distribution that allow to create a simple nodes cluster on the fly. Below a workthrough tutorial.

OpenFaas with Minikube

State of art

Serverless technologies are the new trend that several companies has chosen. Actually there are many implementations of the serverless principles, just some examples

A big challenge is try to define a common standard language for events that fire the functions defined in the API gateway independently from the framework chosen for realize the serverless approach. More about CloudEvents project at

https://cloudevents.io/

Bonus track: Vue.js

In order to write functions in a serverless approach, JavaScript is the way and Vue.js is particularly useful to design functions.

Vue.js conference

Other lectures and references