ISE Blog

FaaS: Function as a Service

Serverless has been a buzzing topic in the cloud community for quite some time now, and with good reason: serverless is great for managing cloud costs and utilization, deploying quickly, and scaling on-demand. While I’ve touched on some serverless elements before, today we’re going to talk about the backbone of serverless computing: Function as a Service or FaaS.

What is FaaS?

Function as a Service allows you to deploy code without worrying about long-running servers for the application code to run on. From the outside, you designate an event which triggers the function, and a deployment package which is the code to execute when the event triggers. When the event is triggered, the deployment package unpacks the event metadata, executes and exits.

The event could be anything from an object being written to durable storage, a periodic timer, a message delivered via queue or streaming service, and with the use of an API gateway, even http requests. The event’s metadata may include things such as the time of the event; name, location and size of an object written to storage; arguments and method of an http request; and even the content of streaming or queue packets.

The deployment package is the code of the function. It can be written in a variety of languages depending on the FaaS platform. The package is loaded into a virtual environment of some kind (typically Docker) and executed with the event metadata passed in. The function then takes some action, may or may not return a value

Strengths of FaaS

Unlike a long-running application, a function can execute as quickly as the platform can scale. The scaling is handled automatically by the FaaS provider, so that the number of events dictate the number of concurrent instances of your function. Those instances each get their own “compute containers” which are created and destroyed in response to events by the FaaS provider.

There is no configuration to manage on these function containers, beyond perhaps the amount of memory dedicated to the function, and the permissions it has to other cloud resources. These settings are generally in the same place as the deployment package itself. Deployment is as easy as defining the event trigger and these parameters, and sending the deployment package to the provider.

Drawbacks of FaaS

FaaS providers have some common drawbacks. The first execution of a deployment package, or even the first execution in a while can have some significant latency introduced as the FaaS provider spins up the first instances of the compute containers - what’s called a cold start. This varies from language to language and typically only occurs when events have not triggered execution for some time.

Execution is also typically time-limited by the provider. AWS Lambda functions, for example, time out at 5 minutes: if your function does not complete, the event goes unhandled. Complex event handling may need several function stages to complete. This time limit means that your application cannot have any internal state. If you need to maintain state across multiple executions then some durable storage will need to be used, such as a database or object store.

While the state of monitoring and tooling is improving in the FaaS space, there’s still a lot of room for improvement. AWS Lambda, a particularly mature implementation, has platform-specific tools such as X-ray to support distributed tracing across AWS Lambda functions, and the Serverless Architecture Model or SAM, to orchestrate interdependent Lambda deployments.

FaaS platforms

The major cloud providers, Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform, each offer their own FaaS solution, each with its own strengths and drawbacks. The differences are small, but each vendor makes tradeoffs to support their large customer bases. The implementation is specific to each provider and so carries with it some vendor lock-in. Third-party frameworks such as the Serverless framework and CloudEvents attempt to abstract those differences and provide a platform-independent solution. There are also open-source implementations of FaaS that are becoming popular, namely OpenWhisk, Galactic Fog, and OpenFaaS.

Function as a Service is an amazing development paradigm, but it’s still relatively new and has a lot of growing to do. While it’s not the solution to everything, there are certainly applications where being quick to market and scaling on demand outweigh the potential disadvantages.

Do you have experience with Function as a Service (Faas)? What has been your experience? Comment below and join the conversation!

Samuel Thurston is a Software Engineer and Cloud Practice Lead for ISE, architecting and implementing cloud solutions for enterprise clients. He enjoys running, yoga, and cooking, and is frequently found on the disc golf course.

Posts by Topic

ISE delivers innovative, end-to-end, scalable IOT and telematics solutions, enterprise mobility applications and tailored software solutions that help companies simplify and solve even their most complex business challenges.

ISE BLOG

Delivering Excellence, Providing Opportunities! Join a company with an award-winning culture where you can collaborate with the best and the brightest while working with emerging technologies! Join the ISE Team!