Skip to content
Snippets Groups Projects
README.md 6.00 KiB

Functions as a Service (FaaS)

Build Status

FaaS is a framework for building serverless functions with Docker which has first class support for metrics. Any process can be packaged as a function enabling you to consume a range of web events without repetitive boiler-plate coding.

Highlights

  • Ease of use through UI portal and one-click install
  • CLI available with YAML format for templating and defining functions
  • Write functions in any language for Linux or Windows and package in Docker/OCI image format
  • Portable - runs on existing hardware or public/private cloud
  • Auto-scales as demand increases

Overview of FaaS

Stack

Function Watchdog

  • You can make any Docker image into a serverless function by adding the Function Watchdog (a tiny Golang HTTP server)
  • The Function Watchdog is the entrypoint allowing HTTP requests to be forwarded to the target process via STDIN. The response is sent back to the caller by writing to STDOUT from your application.

Gateway

  • The API Gateway provides an external route into your functions and collects Cloud Native metrics through Prometheus.
  • Your API Gateway will scale functions according to demand by altering the service replica count in Docker's Swarm API.
  • A UI is baked in allowing you to invoke functions in your browser and create new ones as needed.

CLI

Any container or process in a Docker container can be a serverless function in FaaS. Using the FaaS CLI you can deploy your functions or quickly create new functions from templates such as Node.js or Python.

CLI walk-through

Let's have a quick look at an example function url_ping which connects to a remote web server and returns the HTTP code from the response. It's written in Python.

import requests

def handle(req):
        r =  requests.get(req, timeout = 1)
        print(req +" => " + str(r.status_code))

handler.py

$ curl -sSL cli.get-faas.com | sudo sh

Install the faas-cli which is also available on brew

Clone the samples and templates from Github: