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

Deepak Maheshwari
6 min readJan 29, 2023

--

In today’s world, almost all the capabilities are being described using the “as a service” model. It all started with Infrastructure as a service “IaaS”, Wand now it has expanded in various areas, few examples are database as a service, testing as a service, security as a service, storage as a service, business as a service likewise “Function-as-a-Service (FaaS)” is very popular these days due to adoption of cloud. As per Research and Markets report — the Global “Function-As-A-Service” market is expected to grow from USD 8.59 Billion (2022 market) to USD 20.96 Billion by 2026.

In this article, I am going discussion about FaaS Model but before we take deeper dive into FaaS, let’s understand “serverless architecture”. Serverless architecture is a way to develop, build and run applications without worrying about infrastructure management. The application or database or services still runs on servers but maintenance, provisioning, and scaling are managed by cloud providers.

FaaS allows the execution of a modular piece of code in a serverless manner in most languages such as Java, Python, and Node. The code can be updated or written on the fly. FaaS helps developer to focus on writing business logic while serverless providers take care of executing the code on runtimes and servers. This reduces overhead for developers and enables time to focus on solving business problems that are scalable, reliable, and resilient. Also, FaaS billing is based on real consumption, not on the declared resources needs, therefore it is based “pay per compute usage” model.

Serverless and FaaS are often interchangeably used with one another but the truth is that FaaS is actually a subset of serverless. Serverless can include Compute, Storage, Database, and other services but FaaS is limited to application code executed on certain events.

Let’s understand FaaS evolution -

Software development has progressively enabled levels of abstraction, from physical servers to virtualization to OS / Middleware to runtime to containers to functions, thereby increasing the focus more and more on the code to be written and less and less on the infrastructure to be implemented. Also, as we moved from Hardware to Function, the time to market for any software product has reduced from months to milliseconds. The figure below highlights this trend.

Evolution of Functions

If we take a deeper dive to understand the history based on the above diagram then the following 6 steps should provide enough background around FaaS evolution:

  1. Hardware: In the early days, this is the actual server where applications are deployed. This is the upfront cost of an organization in an on-prem environment and takes months to set up.
  2. Virtualization / Servers / Storage / Networking: As technology advances, virtualization came into the picture. This helped in the “virtualization” of hardware resources with a hypervisor to create virtual machines to enable horizontal scaling.

If we combine above two points then it shows the emergence of “Infrastructure as a service (IaaS)” AWS Cloud offering which changed the entire dimension of running applications on-prem. It has improved to time to market from months/weeks to hours/minutes.

3. Operating System / Middleware: This is the core piece that helps in running the actual program.

4. Runtime: Responsible for execution of the program (for example, Java Runtime)

Now, if we combine capabilities for all above points then it results into “Platform-as-a-service (PaaS)” model. This helps in improving time to market from minutes to seconds and user don't have to worry about hardware, virtualization, OS and runtime etc.

5. Application: This layer is considered as “Software-as-a-service (SaaS)”. SaaS enables cloud-hosted, ready-to-use application software. Users pay a monthly or annual fee to use complete applications or modules based on the licensing cost and agreements.

6. Function: This is the highest level of abstraction where developers don't have to worry about anything except writing their business logic. For example, if a developer is writing stock market comparisons then that’s the only piece of work required by the developer, and the rest of the overhead is managed by the cloud provider. Also, time to market and provision time is in milliseconds.

How FaaS is utilized in various Clouds?

The below picture depicts various FaaS services which are provided by Cloud Providers. Based on this, you can imagine the power which FaaS brings to the table.

Function as a Service (FaaS)

What are the Benefits of using FaaS?

  • Focus more on code, not infrastructure- allows you to focus on the app code which dramatically reduces time-to-market.
  • Pay only for the resources you use — results in cost savings when the code is not running
  • Easy to scale and the platform manages horizontal scaling.
  • High availability — reaps the benefits of cloud infrastructure as the load is split across multiple availability zones per geographic region and can be deployed across any number of regions without incremental costs.
  • Multi-language support, functions can be written in almost any programming language
  • Applications are easy to deploy and update.

Challenges with FaaS…

Below are the keys challenges in the implementation and maintenance of FaaS solutions :

  • Lose control over your own server-side logic can be a challenge
  • Debugging is harder at the server level, no control over what’s happening under the hood.
  • Vendor lock-in, if the organization decides to move to a new vendor then it may cost to upgrade the systems as per the new vendor’s specifications
  • You must write FaaS-suitable code, Cloud providers may have strict constraints in terms of coding standards which might affect the flexibility and customization of code.

FaaS principles and best practices

There are several best practices you can follow to design FaaS easier to design, deploy, and manage in a more effective and cost-efficient way. A few of the important ones are mentioned below:

  • Make each function perform only one task — FaaS functions should be designed to do a single piece of work in response to an event. Make your code scope limited, efficient, and lightweight so functions load and execute quickly.
  • Keep functions short-lived, as they’re intended to execute efficiently, and then power down to open up more compute capacity.
  • Design function as stateless and if data needs to be persisted then store it in the database so that it can be pulled back and forth based on the requests.
  • Keep minimum external dependencies.
  • Enable the ability to test functions locally using IDE, test tools, and testing frameworks to validate the efficiency and functional accuracy of the code.
  • Don’t make functions call other functions, the value of FaaS remains is in the isolation of functions. Too many function-to-function calls can increase computation cost.
  • Consider fine-grain access or follow the least privilege principle for each function to avoid any major security incidents.

What are the use cases for FaaS?

FaaS is much more expensive than a typical IaaS cloud service, so the use cases need to be considered appropriately otherwise it can become prohibitively expensive. Few are the use cases are mentioned below:

  • Event Driven Computing provides loose coupling resulting in service abstraction and isolation, independent scale, and deployment flexibility.
  • On-demand functionality is an overall usage model that is well suited to a FaaS environment. The FaaS user pays only when the feature is active, so the on-demand model is an economical use of FaaS.
  • IoT services send sensor data to the cloud intermittently for analysis.
  • Chatbots need processing only when there is a message flow going.
  • High-volume transactions and workloads that only happen every so often, like generating reports, image processing, or any scheduled tasks. Common FaaS use cases are data processing, and mobile or web apps.

Conclusion

FaaS is an innovative and game-changing technology for some, but it won’t work for everyone. With FaaS, developers have no need to get into the server side of things, and the developers can focus on the coding part of the application, which is a good thing. Also, if users follow the best practices in FaaS implementation then it helps applications to design, deploy, and manage in a more effective and cost-efficient way. Common FaaS vendors include IBM Cloud Functions, AWS Lambda, Alibaba Cloud, Google Cloud Functions, and Microsoft Azure Functions.

At last, even if you are new to FaaS but this market is expected to grow up to USD 20.96 Billion by 2026, so there is never a better time to learn about this market.

--

--

Deepak Maheshwari

Technical Enthusiastic | Sr. Architect | Cloud Business Leader | Trusted Advisor | Blogger - Believes in helping business with technology to bring the values..