Serverless is no longer just a buzzword for Docker it is now a reality. Recently, I had the opportunity to test drive the Docker Serverless project or better known as Docker FaaS (Functions as a Service).
Fellow Docker Captain Alex Ellis is the mastermind behind the project. Docker FaaS started back in December '16 and I started following the project with excitement shortly after. Since then it has made its way into the popular tech news site of Infoworld and gathered impressive feedback from Hacker News. The Docker FaaS project has reached and then surpassed 1,000 GitHub stars while I was writing this article. Impressive!
What is Serverless / FaaS
I detailed the Serverless space back in November '16 in The Insiders Guide to Docker Serverless. Since then the FaaS space has grown substantially from tooling to additional projects.
But for a quick definition, Wikipedia describes FaaS as:
"FaaS is a category of cloud computing services that provides a platform allowing customers to develop, run, and manage application functionalities without the complexity of building and maintaining the infrastructure typically associated with developing and launching an app"
In other words, FaaS makes it dead simple to deploy a highly scalable and cost-efficient application with just a few lines of code without having to worry about the infrastructure or development boilerplates. But making a FaaS dead simple to use with good integration is where the magic is.
Tell me about Docker FaaS
So you might ask yourself why I chose Docker FaaS over the other available frameworks? I'm glad you asked. The features that persuaded me were:
- Integrates directly with Docker Swarm
- Built-in Prometheus metrics
- Any container can become a function
- Ease of use, a one-line script starts everything
- Can launch new functions directly from UI
- Integrate with other services via WebHooks like GitHub
Docker FaaS has two main components; the API Gateway and Function Watchdog.
The API Gateway is responsible for routing external traffic to the functions, collecting metrics for Prometheus, and autoscaling functions via Docker Swarm replicas. FaaS includes a clean UI which allows you to invoke functions and create new functions as needed.
The Function Watchdog runs inside each container. The Watchdog then marshalls HTTP requests between the public HTTP URL the target function.
What's unique about Docker FaaS is that it runs one replica of your function all the time. This enables Docker FaaS to have lightning fast response times when a function is triggered. Other projects requires the trigger of the function to provision a new replica for each trigger. This action consumes precious start time before the function can be executed. When time to execution matters, Docker FaaS is the clear leader.
Docker FaaS Review
My first impression of the Docker FaaS is how dead simple it is to launch the entire FaaS stack. Once the stack is up and running launching the clean and simple UI reveals about 10 sample functions installed by default. These functions range from simple word counting to querying the Docker Hub for Repo's.
When you click on a function the UI opens the function and provides the ability to invoke the function directly. It's possible to pass either Text or JSON to the function and click the
Invoke button which triggers the function and responds with an output.
Creating new functions is available at the click of a button. Once you click
Create New Function. It is easy to define a new function. Alex made a great boilerplate image
functions/alpine which is a great starting point for new functions. This image makes it easy to turn any UNIX process into a function. I chose to use
sha256sum for my demo.
Next, I called the newly created function via the curl command.
curl <ip of Docker host>:8080/function/hash -d "hi"; done
This passed "hi" to the function. The function then returns the hash value as the output. It is possible to pass "hi" directly via the UI as well if desired. Works exactly the same.
Testing the autoscaling capability was very straight forward. Engaging autoscaling was as easy as passing a loop to the newly created
while [ true ] ; do sleep 0.3 && curl <ip of Docker host>:8080/function/hash -d "hi"; done
After the loop runs for a minute or 2 you will notice the Invocation Count increase in the UI and eventually, a number of replicas will scale in increments of 5 and then 10. See the screenshots below of the FaaS UI, the Prometheus graph, and Grafana of how the replicas are scaling with the load.
Docker FaaS Conclusion
From the moment I began testing till now, Alex has improved Autoscaling, UI improvements, and countless other features. I was so impressed with my initial tests that I presented Docker FaaS at 2 different meetups Operationalizing Containers and ETH Polymese and here's the slides Docker Serverless. Now I'm working on how we can integrate this into some development projects and assist Alex with some testing and documentation.
A lot of momentum is building around Docker FaaS. I would encourage everyone to head over to the project page https://github.com/alexellis/faas and try it out, contribute, and provide feedback to the FaaS.
Subscribe to BrianChristner.io
Get the latest posts delivered right to your inbox