OpenFaaS: Serverless with Docker
In a previous post I mentioned FaaS, or Function as a Service, a Docker-based project by Alex Ellis. FaaS leverages Docker to create a clustered environment where developers can deploy containerized functions, which can enable Serverless applications.
FaaS has changed and grown very quickly. It has been officially released with the name of OpenFaaS.
The documentation is getting better every day. People are contributing by proposing new functionality and fixing defects. The community is becoming increasingly active.
It may not be fair to compare OpenFaaS with popular Serverless services like AWS Lambda as they operate in two different use cases (check again my previous post on the differences between Serverless in public clouds and private clouds); however, OpenFaaS provides great flexibility that is pushing developers to experiment with it and build Serverless apps in a way that until now we didn’t considered possible. Since it’s Docker-based, OpenFaaS allows you to create functions with anything that can be run in a container, including binaries.
Originally I planned to write a post describing how to use OpenFaaS to create a simple Serverless app, but it felt as I wasn’t contributing anything special as other people has done this better than I could.
So, instead I want to show three examples other people has written which I believe exemplify the flexibility in both functionality and complexity that OpenFaaS provides.
Build a Serverless Golang Function with OpenFaaS
In this post I want to show you how to build a Serverless function in Go with our new Golang template created with love…blog.alexellis.io
Written by Alex Ellis himself, this blog post walks you through how to build a function using Golang.
Personally, I love Golang and I take every opportunity I have to use it. It’s so lightweight that it feels like a perfect fit for a Serverless app; and I’ve always felt sad that AWS Lambda doesn’t support it natively. OpenFaaS even has a native template which allows you generate Golang functions with OpenFaaS CLI.
This is a simple example that can be extrapolated to use any language you want to build your Serverless functions.
A Serverless GraphQL Blog in 60 Seconds with OpenFaaS
As I’ve integrated GraphQL with OpenFaaS in my previous post (“Integrating OpenFaaS and GraphQL”), what I wanted to do…hackernoon.com
This post is a follow-up of another one called “Integrating OpenFaaS and GraphQL”.
In case you’re not familiar with GraphQL, it is a query language created by Facebook which addresses some of the downsides of REST.
While it is possible to create a GraphQL function in AWS Lambda, I think this is an interesting test case for OpenFaaS as it showcases that it can be used with a framework that is very popular among front-end developers, and it can also leverage your Docker Swarm or Kubernetes cluster to provide other resources like databases.
It might feel counterintuitive to include full GraphQL endpoints in functions (which are supposed to have a single responsibility) I think that a good design will show that it’s the other way around: It allows developers to condense APIs with specific functionality to a single function, no matter the data format the client requests.
Colourising Video with OpenFaaS Serverless Functions
In a previous post I talked about how to deploy serverless functions to an OpenFaaS cluster with ease. This post…finnian.io
I think this is the use case that better showcases the power and flexibility of OpenFaaS. In this example, the function takes a black and white picture and using Machine Learning it returns another image with colors. The function was hooked to a Twitter bot which allows people to tweet black and white images and receive a response tweet with the image in color. The result is amazing:
The function was also applied to video:
Obviously, it requires a great amount of memory for the Machine Learning algorithm to work nicely, but OpenFaaS scales to support it.
You can try it yourself by sending a b&w picture to https://twitter.com/colorisebot.
This is a perfect example on how OpenFaaS supports binary data and integration with non-Serverless specific areas like Machine Learning. Imagine what this kind of integration will be able to do in a not-very-far future.
Multiple companies are trying to push their own solutions for private Serverless. However, OpenFaaS has everything to become the standard for private hosted Serverless architectures: Flexibility, scalability, ease of use and support in well-known technologies like Docker.
Even when it’s a new toolset, the community is doing amazing things with it, allowing it to grow and become a solid choice for people who wants to adopt a function-based development in their projects.