Function as a service (FaaS): What is it and why you should use it?

June 22, 2022
May 29, 2024
Function as a service (FaaS): What is it and why you should use it?

Function as a service (FaaS): What is it and why you should use it?

It has been fourteen years since Google introduced Google App Engine. For the first time, a developer could create a programme and deploy it to Google’s Cloud Platform without worrying about how the server was supplied or whether the operating system needed patching. AWS took notes and launched AWS Lambda a few years later, in 2014. The new model fundamentally changed how we architect, write, deploy and run applications.

What is Function-as-a-Service (FaaS)?

Function-as-a-Service (FaaS) is a cloud computing service that allows developers to write and deploy code without worrying about the underlying infrastructure. FaaS is a relatively new concept and is often compared to Platform-as-a-Service (PaaS) or Infrastructure-as-a-Service (IaaS). However, FaaS is unique in that it focuses on providing a serverless environment for code execution. That means developers do not need to provision or manage servers, which can significantly simplify the development cycle. In a nutshell, it’s just another set of abstraction layers on top of the Cloud Providers IaaS & PaaS offerings. No alt text provided for this image

alter-text
The targets where the respondents are deploying the primary service or application

From The State of DevOps 2021 Report

Why should you use FaaS?

The FaaS model is an excellent option for many applications, especially those requiring short-lived tasks. FaaS is also ideal for applications that require low-to-medium traffic and fast response times.

For example, consider a scenario where your organisation needs to process video files. You could break down this process into a series of microservices or functions. One function could be responsible for extracting metadata, another could transcode the files to a different format, and a third could be responsible for applying a watermark. In this case, providing enough hardware to handle the load would be challenging and costly. However, you could deploy each of these applications as a FaaS function, allowing you to quickly and easily scale up or down as needed.

Some of the advantages are:

  • Simplified management model - The developers can focus more on writing and testing the code instead of managing the underlying infrastructure.
  • Cost-efficient model - FaaS follows the pay-as-you-use, you pay only for the time when your code is actively running.
  • Built-in scalability - FaaS provides automatic, independent, and rapid scaling of functions, as required. When demand is dropped, FaaS automatically scales back down.

Challenges of Function-as-a-Service (FaaS)

One of the main challenges of using a FaaS is deciding on the best architecture for your application. When you are using FaaS, you can’t rely on having control over the servers that your application is running on. That means you need to decide on a more distributed architecture, with your functions communicating with each other over message queues and other services that provide a standard interface between the functions. Therefore, debugging issues is a more tedious because of the distributed architecture. Another challenge is testing your code. When running your functions in a FaaS, you don’t have direct access to the code. That makes it more challenging to write unit tests. When it comes to time-critical projects, you should consider the cold-start and warm-up times.

How to get started with FaaS?

FaaS implementations are available from a variety of vendors. Each has an extensive ecosystem of complementary services and integrations with other services. AWS Lambda, Azure Functions and Google Cloud Functions are the offerings from the three major cloud providers.

Start by educating yourself and setting a goal to become the subject expert in your organisation. It is also essential to establish a good relationship with your cloud provider. They can guide you through your journey and provide you with additional training materials. Many of them offer predefined workshops that you can follow.

Identify a project that fits the FaaS model. It’s typically a small, greenfield project demonstrating the model’s technological and business advantages. You should always start small and remember that “done is better than perfect”. Once you have implemented your first solution, iterate, learn from your setbacks, and improve.

Which programming language to use with FaaS?

Each of the three major FaaS platforms offers a different set of programming language runtimes with which functions can be deployed.

Supported Runtimes per FaaS provider

  • AWS Lambda - Node.js, Python, Ruby, Java, Go, .NET
  • Azure Functions - C#, JavaScript, F#, Java, PowerShell, Python, TypeScript
  • Google Cloud Functions - Node.js, Python, Go, Java, .NET, Ruby, PHP

These are the supported “out-of-the-box” runtimes. If you’d like to use an alternative runtime, you can build one as a Docker container.

Final Words

FaaS will undoubtedly play a significant role in developers’ toolkits. Therefore, it’s essential to understand how FaaS might benefit your business. If your application fits the FaaS model, go for it! It’s an excellent platform for developing, deploying, and running production-grade applications. FaaS is suitable for everyone, whether you are a startup, an SME, or a large organisation, as it provides scalability, flexibility, and lowering the time-to-market at a low cost.

We use cookies on our website

Cookies help us improve your experience, personalize content, and analyze traffic. Click 'Accept' to agree.