Skip to content
15 October 2019

What the FaaS? Cut down your computing costs with serverless computing.

With proper implementation, serverless computing can bring you cost savings throughout the application development cycle. Here’s how to get started with FaaS, short for Function as a Service.

The emergence of cloud computing has moved workloads from on-premise server rooms to public cloud environments. The latest addition to the world of cloud services is serverless computing, which promises to free the user from server management entirely.

Serverless is still a relatively new concept, which means that the tools and platforms related to it are new as well. It can be challenging to find resources, documentation, and best practices related to serverless application development. Serverless is not the solution for everything, and using the wrong technology can actually increase costs for some workloads. But, when used properly, it can come with substantial cost and time savings – see the graphs below.

FaaS is a serverless cloud computing service model that allows developers to deploy individual functions to the cloud. It might sound like just another fancy term, but there are tangible benefits to using serverless computing and FaaS. All you need is experienced cloud engineers to help you modernize your architecture and bring you the best benefits of FaaS and serverless architecture.

What you need to know about serverless computing and FaaS

Serverless computing refers to a concept in which the user does not need to manage any server infrastructure at all. The user does not run any servers, but instead deploys the application code to a service provider’s platform. The application logic is executed, scaled, and billed on demand, without any costs to the user when the application is idle.

No formal definition of serverless computing exists, but the Cloud Native Computing Foundation (CNCF) divides serverless into two cloud computing service models:

Backend as a Service

Backend as a Service (BaaS) refers to third-party services that provide an interface to replace or complement a subset of functionalities in an application. These services are scaled automatically and transparent to the user, creating the appearance of serverless functionality. BaaS services are commonly used by single-page web applications or mobile applications to take advantage of cloud-accessible databases or authentication services. Examples of BaaS services include Google Cloud Firestore and AWS Cognito.

Function as a Service

Function as a Service (FaaS) platforms run small units of code executed in response to an event. The event can be, for example, a request from a web application, an operation in a database, or a queued message from another application. Developers can deploy code to FaaS platforms, and the code is executed on demand based on the events. The service provider handles scaling and infrastructure, so the service appears serverless to the user. Google Cloud Functions and AWS Lambda are examples of FaaS services.

Benefits at every stage of the project

When starting a new project, using serverless architecture can greatly reduce time to market, because there is no need to build infrastructure. Furthermore, BaaS services can reduce the implementation time when an application component is implemented with an existing service. In small projects, developers can focus on the implementation and deploy it to a FaaS platform in mere hours instead of days.

When the project is released, there will be no running compute costs if the service is not used. This is due to the fact that, with FaaS, all resources are created on demand and, with BaaS, the resources are shared and allocated based on needs.

The fact that there are no running compute costs also means that there is no additional cost to scaling the application. The service can be prepared to scale from thousands to millions of users at no cost and minimal effort. You will only pay for what you use. What’s more, operational costs are reduced during project maintenance, because there is no need to provision, update, or manage server infrastructure. This is all handled by the cloud service provider.

The usage of computing resources is more efficient, because the serverless resources are shared or short-lived. With serverless services, cloud providers can share resources between customers, with no need to reserve resources for idle capacity, as they are allocated on demand. Serverless computing can lead to “greener” computing, in which less computing power is wasted on idle capacity.

As an example, FaaS could be used to implement functionalities related to a campaign that is part of a larger service. Instead of modifying the existing service, the functionality would be implemented as a serverless FaaS application. The serverless application can then be easily removed at the end of the campaign. This can reduce risks, implementation times, and development costs in comparison to modifying existing applications.

Use cases

Serverless architectures are more suitable for certain types of workloads. In general, serverless is a good fit for workloads with the following characteristics:

Easy to divide into small independent units.
Infrequent or sporadic traffic patterns.
Do not suffer from long startup times.
Need for increased developer velocity or reduced time to market.

In contrast, serverless computing might not be suitable for the following workload types:

Long-running tasks needing intensive computation power.
Workloads that need to be executed instantly without any delays.

Suitable applications for serverless computing include short scheduled tasks that need to be executed periodically, serving AI and machine-learning models, deployment pipelines, and logic executed in response to database changes. One good example would be an automatic image-resizing functionality. When a user saves an image to cloud-accessible storage, a FaaS function will receive an event and resize the image to a thumbnail size and save the result back to the cloud storage.

Another example of an efficient use for serverless computing would be creating a custom functionality in a messaging platform. Many messaging platforms offer the user the ability to create custom commands that execute custom functionalities and return a result to the user. An FaaS function that would be triggered by a custom command could, for example, return the daily forecast for the requested area. Development time would be reduced greatly, because there would not be any need to set up infrastructure.

Startup latency can be a challenge

When an FaaS function is invoked, there may not be enough resources available to execute the function instantly. The startup time will be short when the resources have already been allocated, but if they need to be allocated before execution, it will increase the startup time. These high startup times are called cold starts. Cold starts take more time because of the need to initialize the execution environment and application code, which can cause a delay lasting from some milliseconds to several seconds.

Cold-start latency comparison between different serverless platforms.

High delays do not usually matter for background tasks, but for time-critical applications, like web applications that serve end users, a delay of a few seconds might not be acceptable. The startup delay varies between different serverless platforms, as indicated in the image above. Even the choice of programming language can have a significant effect on cold-start times.

Monthly cost comparison of different serverless platforms (HTTP traffic).

Latency is not the only thing that varies between serverless platforms. The cost differences between different platforms can also be considerable. As can be seen from the image above, while AWS Lambda has the lowest startup latency, it also has significantly higher expenses when handling high traffic volumes in comparison to Google Cloud Functions and Google App Engine.

Serverless can bring considerable cost savings when used properly but, for some workloads, using the wrong technology can actually increase costs. It is thus essential to know how and when to use serverless technologies.

Illustration: Jukka Forsten

Written by

Olli Paakkunainen

There are two things Olli takes seriously: serverless computing and tea. Actually, there are a lot more things Olli takes seriously, but because of him, our office has a really good water boiler and a great variety of teas.