Interested in Solving your Challenges with XenonStack Team

Get Started

Get Started with your requirements and primary focus, that will help us to make your solution

Proceed Next

Deployment Automation

Function-as-a-Service (FaaS): Introduction, Working and Use Cases

Gursimran Singh | 24 November 2022

Function-as-a-Service

Introduction to Function as a Service (FaaS)

Before we dive into Function as a Service (FaaS), let's see what the journey has been before it. Physical Servers > Virtual Machines > Containers > Functions Earlier Physical Servers were used to run applications. Though they offered good performance, they were meant to support the working of only specific applications only. If another application were to run on them, it would affect the workflows of both. The rise of Virtual Machines in 2001 allows enabling application-specific resources from physical machines to V M instances running. This decreased the infrastructure concerns related to particular applications on physical servers. Then Docker containers came, which provided a lightweight alternative to Virtual machines by encapsulating only application, and it is specific dependencies inside a container.

Enables the Serverless Computing by firing off bits of code, freeing the developer from managing infrastructure and enables to simply write business logic code. Source: Running Faas on a Kubernetes Cluster

Functions make the developer's process even more autonomous. Functions are code snippets inside the container. Execute them based on some events. For example, A function can be made which creates a database, and on creation, it populates that database with values. Without functions, developers would have to wait for database creation and then manually update the database.

Other Cloud Models

Apart from FaaS, we have other cloud models:

  • PaaS: Platform as a Service

PaaS provides a software development environment to clients by providing all software tools to developers in one place in an organized manner.

  • SaaS: Software as a Service

Here the provider does not expose Virtual machines or networks to the user; instead provides him with access to software services such as databases. So the client doesn't need to worry about the OS and focuses on software.

IaaS: Infrastructure as a Service

Here the client is provided by full infrastructure such as networks, Virtual machines, etc. In other terms, it is called " Cloud Computing ."

VNFs are hosted on Commercial Off-the-Shelf (COTS) computing, networking infrastructure, and storage. Click to explore about our, What are Virtual Network Functions ?

What is Function as a Service (FaaS)?

Function as a Service is a cloud service execution model and uses functions for the purpose. As stated above, Function is a piece of code of business logic, more particularly, which is event-driven. That means that it gets triggered and performs its part on a launch of a particular event until the task is done. Functions can be of various types such as :
  • Function to process a web request
  • Function for any scheduled job
  • A function that executes manually.
Moreover, we can also chain functions, which means a particular function on completion can trigger another function to execute. For example, A function for web requests on completion can trigger any scheduled job function. This way, the process becomes more autonomous.
Quickly turn anything into a serverless function that runs on Linux or windows through Docker or Kubernetes. Source: Serverless Architecture with OpenFaaS and Java

List of Function as a Service Service providers:

Below is a sample example of an Azure function snippet. Using System.Net; public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) {     log.Info("C# HTTP trigger function processed a request.");     // Get request body     dynamic data = await req.Content.ReadAsAsync<object>();     return req.CreateResponse(HttpStatusCode.OK, "Hello " + data.name);

How does Function as a Service Work?

Anyone who wants to get the benefits of FaaS needs to use a cloud service provider to implement it.
  • In its model, developers are not concerned with infrastructure and service-related computing, and they are only concerned with writing functions.
  • These functions on getting invoked will cause the cloud provider to bring up the server, and on the successful execution of the Function, the server goes down.
  • These servers get available on demand when the Function invokes and goes down until the Function executes. Thus saving cost for the subscriber of cloud services as well.
Java vs Kotlin
Automating enterprises for Cloud-Native Transformation and migration to Hybrid and Multi-Cloud Solutions. Cloud Infrastructure Services and Solutions

What is the Serverless Architecture of FaaS?

Serverless architecture is a far broader concept than FaaS. With a large number of workloads now shifting to the cloud, cloud providers need to provide backend services like
  • Load balancer configuration
  • Cluster management
  • Operating system to support the workloads etc

These are known as BaaS (Backend as a service). And serverless architecture comprises FaaS and BaaS. For example, in databases, many BaaS solution providers provide data validation mechanisms so an application can use these at its backend to authenticate with the database. Now it comes into play. Consider the case when a new record is inserted into the database. Using it, a small function can be added inside the application container, triggered when a new record is added inside the database. The serverless architecture makes it more reliable and affordable. It promotes the trend to implement things as services and use API gateways to map HTTP requests with those functions.

Best Practises for adopting Function as a Service

Few questions you need to ask yourself before going for FaaS services would be:

  • Will FaaS bring a positive impact on daily development workflow?
  • Do we have the budget to afford its services, and how it will lead to the efficient development of our project?
  • What is the purpose of subscribing to its services in our project?
  • Which FaaS provider would best suit your purpose.

These are the few questions you need to keep in mind before implementing it to your workflow.

Serverless Architecture offers huge advantages for companies seeking to transform at scale and support digital journeys. Source: The next wave of Enterprise Offerings

What are the most common use cases?

Below listed described are the use cases of Function as a Service:

On-demand Functionality

One most effective use case of FaaS would be its ability to provide "on-demand" functionality. The "on-demand" functionality enables the powering down feature of any infrastructure leading to cut down the cost, and billing would drastically get lower. You can view the AWS ( Amazon Web Services).

Built-in Quality

In terms of availability, security, and maintenance-related tasks, these cloud provider servers are beneficial; otherwise, have to manage manually alongside.

Simplified Developer Logistics

The development team loves Faas service as it simplifies application development, and sending updates to users becomes smooth. With server infrastructure fully optimized, software developers and teams can focus more on what they are best doing. This leads to faster development, faster updates, and response to customers.

Java vs Kotlin
Cloud Migrations Services and Solutions for establishing a reliable and scalable solution for your enterprise. Cloud Migration Services

Conclusion

In the end, it all comes down to you and your work environment. Identify the FaaS whether it is suitable for your environment or not. Like every other workflow that works for a particular set of needs and fits in certain situations, the same is the case with FaaS.

Table of Contents

Get the latest articles in your inbox

Subscribe Now