What is Function-as-a-Service (FaaS)?
Function-as-a-Service, or FaaS, is an event-driven computing execution model that runs in stateless containers and those functions manage server-side logic and state through the use of services.
It allows developers to build, run, and manage those application packages as functions without having to maintain their own infrastructure.
FaaS is a way to implement serverless computing where developers write business logic that is then executed in Linux containers fully managed by a platform.
Usually that platform is in the cloud, but the model is expanding to include on-premise and hybrid deployments.
Serverless abstracts infrastructure concerns like managing or provisioning servers and resource allocation from developers and gives it to a platform (like Red HatⓇ OpenShiftⓇ), so developers can focus on writing code and delivering business value.
A function is a piece of software running business logic. Applications can be composed of many functions.
Using a FaaS model is one way to build an app with a serverless architecture, but with the increase in popularity of the serverless paradigm, developers are looking for solutions that support building serverless microservices and stateless containers.
Some popular examples of FaaS include:
- AWS Lambda
- Google Cloud Functions
- Microsoft Azure Functions (open source)
- OpenFaaS (open source)
How does Function-as-a-Service work?
FaaS gives developers an abstraction for running applications in response to events, without managing servers. For example, uploading a file could trigger custom code that transcodes the file into a variety of formats.
FaaS infrastructure is usually metered on-demand, primarily through an event-driven execution model, so it’s there when you need it but it doesn’t require any server processes to be running constantly in the background, like platform-as-a-service (PaaS) would.
Modern PaaS solutions offer serverless capabilities as part of common workflows that developers can use to deploy applications, blurring the lines between PaaS and FaaS.
In reality modern applications will be composed of a mix of these solutions: functions, microservices, and long running services.
A cloud provider makes your function available and manages resource allocation. Because functions are event-driven, not resource driven, they are easily scalable.
There are architectural constraints in order to enable some of these benefits, like time limits on the execution of a function, so a function needs to be something that can start up and run quickly.
Functions start within milliseconds and process individual requests. If there are several simultaneous requests for your function, then the system will create as many copies of the function as needed to meet demand.
When demand drops, the application automatically scales down. Dynamic scaling is a benefit of FaaS, and is cost-efficient as well, because providers only charge for the resources that are used, not idle time.
When running on premise, this dynamic nature can also increase your platform density, allowing more workloads to run and optimize resource consumption.
An event-driven service that needs horizontal scaling can work well as a function, as well as RESTful applications.
FaaS works well for high volume transactions, workloads that only happen every so often, like generating reports, image processing, or any scheduled tasks. Common FaaS use cases are data processing, IoT services, mobile or web apps.
You can build an entirely serverless application using FaaS, or comprise an application of partially serverless and partially traditional microservices components.
Benefits of FaaS
- Increased developer productivity and faster development time
- Not responsible for server management
- Easy to scale and horizontal scaling is managed by the platform
- Only pay for or consume resources when necessary
- Functions can be written in almost any programming language
How do FaaS and serverless differ?
Initially, FaaS and serverless meant more or less the same thing, but serverless has expanded to mean a larger set of architectural patterns and practices that make extensive use of common services in addition to custom business logic encoded in FaaS.
Serverless can be used by microservices and even traditional apps, as long as they can be containerized and adhere to the dynamic scale and state management requirements.
The term "serverless" is also being used to represent managed services, like databases and messaging systems, where a developer or administrator is not required to operate the system since it's being managed by a cloud provider or third-party company.
The combination of FaaS and common back-end services (such as databases, messaging, and authentication) connected primarily through an event-driven architecture is what provides the best benefits for serverless developers.
A container and Kubernetes platform for faster deployment of cloud-native applications.
A selection of application runtimes and frameworks well-suited for developing cloud-native apps.