An Introduction to Function as a Service (FaaS)
Published: 2022-08-08 05:19:00

Serverless architectures have been growing rapidly in popularity. This has taken off after AWS introduced Lambdas in 2014.

According to Verified Market research’s recent [study](https://www.verifiedmarketresearch.com/product/serverless-architecture-market/), the serverless market is expected to reach a staggering $36.84 Bn by 2028 with a CAGR of 21.71%. Here’s a primer on this space.

![Market Size](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zj507mh7utek8u010kp.png)

Serverless FaaS is one of the more popular cloud deployment options. FaaS (Function as a Service) is an event-driven way of executing code where you deploy code as functions, better suited for lightweight and standalone apps.

Over the years, applications have been moving from monolithic architectures to microservices. These enable more modular components that allow developers to can create and modify small pieces of code which can be easily implemented into their codebases. Similarly, using FaaS, these microservices can be deployed to the serverless cloud as Functions. The combination of deploying code as functions and FaaS offerings makes it faster to deploy application code without worrying about underlying server management.

![Monolithic to Microservices to functions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gi56y26e1352pr3x1m3h.png)

(Image source: [Cloudflare](https://www.cloudflare.com/en-in/learning/serverless/glossary/function-as-a-service-faas/))

## Key benefits of serverless FaaS

The key benefits are increased speed of shipping code, cost-efficiency, and built-in scalability. With FaaS, server management complexity is removed and all the resources are automatically scaled up and down based on the traffic/events. There are also zero charges for idle time, you only pay for the compute time used. Major cloud providers also provide generous free tiers based on the number of requests and CPU usage time.

![Key Benefits](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2dcr34zvnhpgzjcy5d2b.png)

## FaaS use cases

Here are a few of the countless use cases of serverless FaaS:

- Modular applications like chatbots, backend for IoT
- Scheduled batch jobs
- Health checks, telemetry, alerts
- Data analysis, AI & ML model training
- Offsite backups

Over 1/3rd of all companies using AWS Lambda are startups with <50 employees. And nearly 2/3rd of all AWS Lambda customers have revenue of <$50M. (Data: enlyft.com) Lambda has enabled companies to start small and scales as they grow.

![Companies using FaaS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z6a0ny24xq17haqd9q2p.png)

## AWS Lambda

AWS Lambda is the most popular FaaS offering with 46% of developers [surveyed](https://www.cncf.io/blog/2020/08/14/state-of-cloud-native-development/) using or considering it, followed by Google Cloud Functions and Azure functions. Netlify, Cloudflare, and Twilio also offer FaaS. (The State of Cloud-Native Development Q3 2021 - Slashdata)

AWS Lambda also leads when it comes to the availability of community projects, third-party tools, and frameworks. Many other FaaS projects such as Netlify functions are built on top of AWS Lambda; their aim is to make it even easier to start with serverless while also adding more features. This further increases the appeal for anyone interested in using FaaS for their application.

![AWS Lambda the top serverless choice](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xjb5f3dhwvukmvvedwcj.png)

## Programming language support

Programming language support varies by provider and could impact your choice of FaaS. Node and Python are the two most popular languages on AWS Lambda. 60% of the companies surveyed deployed lambda functions in at least three languages (Datadog: State of Serverless 2022).

Comparison of programming languages supported by AWS, Azure, and GCP. AWS Lambda and Azure Functions also have the ability to support more languages through an abstraction layer. We found this comparison chart from [Techtarget](https://www.techtarget.com/searchcloudcomputing/tip/Compare-AWS-Lambda-vs-Azure-Functions-vs-Google-Cloud-Functions) which gives more info on the supported runtimes.

![Languages supported](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ul1990y550u4nvk433px.png)

## Cost of FaaS

When it comes to cloud costs, especially serverless. There are generous free tiers on offer from the major cloud providers AWS, GCP, Azure, Alibaba cloud, and IBM.

By leveraging the free tiers, startups and independent developers save big on cloud costs. Even those companies whose usage exceeds these free tiers, only end up paying for the amount of usage beyond the free tier limits.

### Free tiers compared

The table below compares the free tier serverless FaaS offerings from AWS, Azure, and GCP.

![Free Tiers compared](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/20wrozn608tuyrexarta.png)

An important thing to keep in mind is that though the free usage is based on duration and requests, there are additional costs associated with things such as network and storage usage, etc. They look like:

![Usage pricing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3lvwc4kga9n99oaa5023.png)

### How to calculate costs?

Calculating serverless costs doesn’t have to be difficult.

You can use tools like [serverlesscalc.com](http://serverlesscalc.com/#) or Dashbird’s [cost calculator](https://dashbird.io/lambda-cost-calculator/) to get estimates of your serverless FaaS costs. AWS provides its own [cost calculator](https://calculator.aws/#/addService/Lambda).

### Newer options

[Netlify functions](https://www.netlify.com/products/functions/) and [Vercel functions](https://vercel.com/docs/concepts/functions/serverless-functions) abstract away a lot of work for you by automatically provisioning load balancers, or by making the deployment process much easier. Convenience comes at a cost, and their costs tend to be slightly higher than that of AWS Lambda. You can evaluate it based on your team size, workloads, and usage.

## Edge functions

Lambda @Edge, Cloudflare workers, and [fly.io](http://fly.io/) provide edge deployments to bring serverless functions closer to your users, reducing latency to an absolute minimum. They're great for real-time work but are pricier than classic serverless FaaS.

Here is a bit more context to help you decide if this is relevant for you.

![Edge Functions vs serverless functions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3gvt9273y1iwfzgkrqh.png)

(Data source: [Fauna](https://fauna.com/blog/comparison-faas-providers#pricing) and [stackpath](https://blog.stackpath.com/edge-serverless-vs-cloud-serverless/))

## Tools and resources

There are several projects, frameworks, and tools that have made shifting to serverless super easy. Here are the must-haves.

1. **[Serverless Stack (SST)](https://sst.dev/)** helps devs build full-stack serverless apps and lets you test and work on Lambda live. REST APIs, React apps, Next.js apps, Cron Jobs, and more.
2. **[AWS SAM](https://aws.amazon.com/serverless/sam/)** is an open-source framework for building serverless applications faster. Its powerful shorthand syntax can express functions, APIs, databases, and event source mappings. With a few lines of code, you can define the application you want and model it using YAML.
3. **[Netlify functions](https://www.notion.so/Tweet-thread-3-7c1d8f9994ad40619f63c6595e1137e3)** allow you to do more by deploying the functions you write as full API endpoints. You can deploy backend functions and frontend code together. Easily preview and roll back deployments.
4. Observability in serverless
Tools like [Datadog](https://docs.datadoghq.com/serverless/), [Splunk](https://www.splunk.com/en_us/solutions/serverless-monitoring.html), [Thundra.io](https://www.thundra.io/), [New Relic](https://newrelic.com/platform/serverless-monitoring), and [Dashbird](https://dashbird.io/) make monitoring and debugging serverless applications easy. They collect metrics, logs, and traces from AWS Cloudwatch and X-ray.

5. **[sls-dev-tools](https://aleios-cloud.github.io/sls-dev-tools/)** is an open source tool that brings your lambda stats, checks recent calls, and more to your terminal. It is compatible with IaC tools from serverless framework to the AWS SAM.
6. **[docker-lambda](https://github.com/lambci/docker-lambda)** is a local sandboxed environment that replicates a live Lambda environment including the installation of software and libraries. You can use it to run functions to observe their behavior and also to compile native libraries.
7. **[Zappa](https://github.com/zappa/Zappa)** is the easiest way to deploy your Python apps on AWS Lambda + API Gateway. It allows easy packaging, deploying, scheduling, rollbacks, and more. It also supports Django and Flask apps.
8. **[Vercel serverless functions](https://vercel.com/docs/concepts/functions/serverless-functions)** enable you to store functions co-located with your code and as a part of your Git workflow. Auto-scaling and edge caching enable quick response and avoid downtime.
9. **[Aqua’s serverless container functions](https://www.notion.so/Tweet-thread-3-7c1d8f9994ad40619f63c6595e1137e3)** ensure that serverless functions are secured and in compliance. It integrates with your CI/CD pipelines and protects AWS Lambda functions in runtime.

---

Deploy easily to AWS Lambda with [Argonaut](https://www.argonaut.dev/?utm_source=dev-to&utm_medium=intro-faas)

- Automatically syncs with your Git source and AWS
- Deploy your NodeJS, Python, Java, and Go apps in minutes
- Quick to setup, scale as you grow