Free up to 1MM monthly messages. No credit card required.
Functions-as-a-Service (FaaS) is a cloud computing model that can be thought of as the plug-and-play of web-based application development. As the ultimate form of serverless computing, FaaS enables developers to deploy production-ready code to the web without having to plan, provision, or maintain any infrastructure or computing resources whatsoever.
It’s not a wholly new cloud paradigm, but adoption of the FaaS model has now matured to a level where it is billed to overthrow PaaS as the new king of serverless computing in 2018 and beyond. In this post, we take a look at how FaaS works, its use cases, and its benefits.
The purpose of FaaS is to help developers take over the world rapidly build, deploy, and extend apps by letting other people (e.g. the Ops folk in DevOps) create and manage the complete server environment on which code can be run. You simply bring the code in the form of individual functions and your FaaS platform does the rest, regardless of whether you’re developing for web, mobile, or IoT.
The elimination of server administration and operations-related duties means no more forgetting where you placed your SSH keys and the simple bliss of doing what you do best – solving problems with code and turning ideas into apps. Hakuna matata, in other words.
Behind the scenes, a FaaS platform typically takes care of the following:
Then, your FaaS provider hands you the proverbial keys to the kingdom of your own serverless compute cloud, with which you can upload and execute your handcrafted code on demand, instantly.
But that’s not all FaaS is about. In contrast with its sibling model, PaaS, which provides a similar “look ma, no servers” approach, FaaS also offers automatic elastic scaling (fully managed by the provider) and a precise, per-execution pricing structure based strictly on how long your functions take to execute.
While it’s tempting to say, “it just works”, you likely want to know how FaaS works, at least on a basic level. So let’s start by defining what a function is.
What is a function? In computer programming, a function is a single-purpose, reusable piece of code that performs processing of arbitrary data (input), and then returns a result (output). Fortunately, as a fundamental programming concept, functions are functions no matter what language you code in.
A simple function in JavaScript might be a piece of code that calculates the square of a number that is given as an input parameter. Usually, this function will be bundled as part of a larger application codebase, residing on a permanent server. With FaaS, however, this function can be uploaded to the cloud and then called on demand whenever it is needed.
Here, FaaS aligns with the concept of Microservices architecture, as each function you deploy becomes its own independent microservice able to be accessed with a basic HTTP request. The result of a function call will typically be returned in JSON format, making it possible to code functions that communicate with other functions which may have been written in another programming language, in true Microservices style. Once your function is live, it can be called from your main application, an event-driven gateway API, or from within other functions that you create.
As a summary, here are the main characteristics of functions in FaaS:
FaaS can be extremely useful in diverse scenarios ranging from hobbyist-level IoT to enterprise web applications. In theory, the use cases for FaaS are limitless, but there are a number of existing trends in development that lend themselves well to serverless functions. As mentioned, Microservices-based apps are a natural fit to make use of FaaS, since an application can be entirely composed of functions that intercommunicate and exchange information on-the-fly.
Some common use cases are listed below:
… And the list could go on. Take a look at PubNub Functions to get a more comprehensive idea of what types of services are available to be run as a function, courtesy of our closest partners. And, of course, where a function doesn’t currently exist to meet your purpose, creating and deploying one is just a few lines of code away.
Let’s say you have an idea for a healthcare app, but don’t have the expertise or budget to provision your infrastructure in a HIPAA-compliant manner. FaaS presents an excellent solution to this kind of scenario: you simply sign up with a FaaS provider that has the necessary compliance and regulatory framework in place, and use their serverless environment to build your app. It couldn’t get any easier.
That’s one major benefit for the enterprise, but how about for developers more generally? Here are a few of the benefits you can enjoy by going serverless:
Display real-time notification badges with PubNub and React Native to display important information and bring users back to your...
Michael Carroll
The concept of Digital Twins has evolved over the last two decades, however, one thing remains the same: the need for real-time...
Michael Carroll
Learn the ins-and-outs of PubNub message size and get a better idea of how many text characters fit in a single message.
Michael Carroll