Learning

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

clock-icon

10 minutes read

writer-avatar

Luis Minvielle

Aug 08, 2024

Share on:

linkedin-icon

The Function-as-a-Service (FaaS) cloud service model, a subset of serverless in which developers only pay for the functions they use, is being increasingly adopted by big names which include Shell , KPMG, or the job board Dice. The market cap of FaaS is expected to grow by almost $70 billion in the next seven years, which compares, for example, to the projected revenue of some of pharma’s biggest players.

It’s also being pushed by big vendors, with AWS, Google, IBM, Microsoft, and Alibaba all reportedly offering functions as a service. But it was not originally a big vendor idea, with plenty of sources pointing out it was first offered in the early 2000s by niche players—and was originally meant for rising, SaaS companies. Using functions offers exactly that kind of versatility: Since providers can scale up or down functions and take care of the cloud management, companies big or small can launch projects on FaaS and then scale up when the time comes. They’ll only pay for what they use.

But FaaS is only this promising if the provider understands its audience. Tech giants might have a FaaS offering—but that doesn’t mean it is optimised for microservices, ready for entrepreneurs or SaaS companies, or affordable. In this article, we’ll dig deep into FaaS and explore why companies are choosing to use functions (and why some companies are not!). If you’re considering a serverless FaaS design and need help choosing the right platform, read on.

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

Function-as-a-Service (FaaS) is a serverless model that allows developers to create and execute functions while outsourcing the cloud management aspect to a provider. Functions are usually triggered by things like uploading files or sending an HTTP request, and, since they’re independent, FaaS is remarkably easy for managing code or implementing microservices. As a cloud computing service model (service model, as in, a way in which providers can offer environments in the cloud), FaaS stands out specifically for how scalable it is.

Instead of having to manage servers, operating systems, or even entire application runtimes, developers using a FaaS platform can focus solely on writing specific functions or pieces of code. These independent functions are designed to perform a particular task, such as processing a payment, sending an email, or resizing an image. Once written, these functions are deployed to a FaaS platform, where the cloud provider handles the hardware, middleware, security checks, operating systems, code execution, and everything else that running an app takes. The cloud provider automatically allocates and scales resources based on how often the application is used.

Functions are a good representation of serverless computing , a model in which developers don’t have to worry about managing servers. In fact, FaaS is a specialised form of serverless computing designed for running short code snippets triggered by specific events. This makes it particularly well-suited for building microservices architectures, where applications are composed of many independent, scalable services working together.

When to use Function-as-a-Service (FaaS)

FaaS is particularly well-suited for applications with unpredictable workloads, or apps in the early stages of development. It can automatically increase or decrease resources based on demand, which is useful for handling unpredictable traffic patterns like those in event-driven systems or applications. FaaS functions are also well-aligned with short-lived tasks triggered by specific events. If you’re building a passion project that you aspire will become a million-dollar SaaS, a FaaS will mean that you won’t incur in extra costs while it’s small, and your solution won’t crash when it suddenly takes off.

FaaS can run productive apps and thoughts-in-progress alike. Since it can integrate with multiple systems with easy, it’s suitable for mock-ups, proof-of-concept projects and MVPs.

Serverless Computing: When to Go Serverless? →

What are microservices?

As its name suggests it, microservices revolve around breaking down a software application into smaller, independent services. Instead of a single structure where everything is connected, and all parts work together, this model allows each service to focus on a specific part of the application and can be deployed separately.

Microservices are very good for entrepreneurs or busy developers because they already provide out-of-the-box functionalities that tech workers can access and use. For example, a microservice that solves authentication will mean that the developer won’t have to code it from scratch.

Microservices are also good for working with big development teams. By breaking the application up into smaller, manageable services, different teams can work independently without affecting each other’s progress. Microservices often involve separate databases and deployments for each service, but the main purpose is to make units that can be developed and released independently.

alt_text

Source: Javan Cipta Solusi

It’s important to note that microservices bring their complexities to the table. If a big developer team is working with the technology, there’s, obviously, a big effort in coordination involved. Not all applications benefit from a microservice architecture. Smaller, less complex applications might find a monolithic structure more suitable. As many developers put it, the decision to adopt this approach should be based on organisational factors rather than solely technical considerations.

If you feel buoyed up, here’s a funny and offbeat video that deals with microservices. It seems to be so influential that some developers have decided to study frontend instead of becoming restaurant chefs.

How do microservices integrate with FaaS?

FaaS and microservices work well together. FaaS is a good way to run microservices. Each service can be set up independently. This method makes managing microservices easier by removing the need to create and manage infrastructure for each one.

By using FaaS, microservices can be scaled independently based on demand, and developers can focus on writing service logic rather than infrastructure concerns. Also, FaaS makes it possible to use microservices that are triggered by specific events. For instance, a user uploading an image to a website might trigger an event (a microservice) to process that image. This event-driven approach allows IT systems to acclimate quickly to changes. Contrast this to an on-premises deployment, in which an unexpected request — such as just _one _additional user trying to upload just _one _additional image — could make the website crash. This is because the on-premises servers might not be ready to scale up — there’s only so much they can process.

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

FaaS offers several benefits for developers and organisations. Primarily, it makes development quicker by eliminating the need for managing servers manually. This lets developers focus on application logic instead of infrastructure.

  1. FaaS is less expensive and less time-consuming than the microservice arhitecture

FaaS significantly reduces operational overhead by handling server maintenance, security, networking, and disaster recovery. It also simplifies deployment, versioning, and logging processes by providing pre-built functions and SDKs.

The cost-savings are another important advantage. FaaS differs from traditional cloud computing by charging only for active compute time. This pay-per-use model eliminates the costs of idle resources, so organisations only pay for the compute resources used during a programme’s runtime.

  1. FaaS scales automatically

FaaS’ automatic scaling capabilities makes it particularly good at handling fluctuating workloads. This means applications can handle spikes by automatically adjusting resources based on usage, without the need for manual intervention. This feature can be referred to as elasticity. But for workloads that need constant compute resources or tight coupling between components, traditional approaches might be a better choice.

alt_text

Source: Hubspot

  1. FaaS is easy to debug and easy to work with

FaaS makes debugging significantly easier by isolating function logic. Each serverless function is a stateless mini app. Stateless functions can be tested independently. Also, many serverless vendors provide simulators, which mimic specific cloud conditions for testing.

FaaS platforms often support multiple programming languages.. Some platforms go as far as supporting multiple frameworks, including Next.js, ExpressJS, Fastify, React, Vue, Angular, Svelte, or even Flutter (this depends on the provider, of course). Some platforms also provide pre-built APIs to speed development up.

AdvantageWhat it means
Quicker developmentDevelopers can concentrate on programming because they’re not handling infrastructure or servers.
Reduced operational overheadThe provider handles server maintenance, security, and deployment processes.
ElasticityThe platform automatically adjusts resources based on workload, handling traffic spikes.
Cost reductionThe provider charges only for active processing time.
Improved debuggingIf built with microservices, the platform isolates function logic for easier debugging and testing.
Developer flexibilityA good provider supports multiple programming languages and, occasionally, provides pre-built functions.

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

While FaaS users offload the management of servers, security, and databases to the provider. this abstraction can limit a developer’s control over these components. Also, debugging can be more difficult because the system is less visible, unless the platform has specific features to help identify errors, such as a typesafe environment.

Vendor lock-in is a significant concern. Moving to a different provider can be difficult and may require code changes. Using a single vendor for backend services can make it hard to move and increase costs. Using a dedicated serverless service provider can reduce this risk.

Cold start latency affects how fast a program starts when it is first called. This can lead to a poor user experience, especially for functions that are rarely used. Yet, cold starts can sometimes lead to better system architecture by pushing developers to rethink poorly designed APIs. (Still, if you choose your provider well, cold starts shouldn’t be that much of a problem).

Security is another consideration. As multiple functions share the same underlying infrastructure, there is always some risk of security breaches, especially if sandboxing mechanisms are compromised. The service provider you pick will make a great difference here, as there are dedicated providers that offer a set of built-in security features that can significantly mitigate security risks.

Alleged DrawbackWhat It Means
Vendor lock-inMigration between providers can be disruptive and require code changes.
Security concernsSharing resources with other users or not having a typesafe platform involves inescapable risks.
Limited developer controlLow system visibility can make debugging difficult, but this drawback is more typical of monolithic applications.
Cold startsFunctions take time to get started on first invocation — unless the provider has taken measures to avoid this.

FaaS development made easy with Genezio

FaaS offers a flexible and secure approach to app development. By abstracting away infrastructure management, developers can focus on core functionalities, accelerating development cycles. This model is particularly beneficial for startups, DevOps teams, and individual developers seeking to rapidly deploy and scale applications.

Genezio offers a developer-friendly FaaS environment that simplifies building and scaling modern applications that can adapt to changing demands. By focusing on type safety, automatic scaling and a user-friendly experience, Genezio helps developers worldwide deploy code quickly and safely. Its cold start times have even proven to be up to four times faster compared to AWS Lambda. Developers have taken their TypeScript code to the cloud in less than 2 minutes by using Genezio.

Find out more about the benefits of FaaS and type-safe serverless development with multiple builds at Genezio.com .

Subscribe to our newsletter

Genezio is a serverless platform for building full-stack web and mobile applications in a scalable and cost-efficient way.



Related articles


More from Learning