The term serverless computing can be misleading; how can you compute things without a server? Well, the answer is that you don't. The term "serverless" comes from the idea that the server is abstracted from the developer, and is totally maintained by the cloud provider. In other words, the developer doesn't really care what environment their code is run in; they just need it hosted somewhere where it can be executed. This removes the responsibility of infrastructure configuration and maintenance from the developer, but naturally gives them less flexibility and control over the environment.
If you work with the cloud, you are no doubt familiar with the terms IaaS, PaaS, and SaaS. There are, however, a lot more! When we look at types of serverless architecture, the main ones are:
In this post we will focus on FaaS, as it's one of the most versatile types of serverless computing and is the most commonly used. In fact because it's so widely used, the terms serverless computing and FaaS are often used interchangeably. However we know from the above that this is not entirely accurate.
FaaS provides a cloud computing service for building and executing functions. The two key properties of FaaS are that it's:
We've already touched on the first point; this means that FaaS is designed for use cases where the developer doesn't care about the environment in which the code is run, or the infrastructure behind it. They only care that it executes and performs it's function, hence a serverless architecture being the optimum choice for this scenario.
With FaaS, functions are executed in stateless containers. A stateless application does not retain any client information on the server from one session to the next. Therefore, FaaS is ideal for executing small, self contained pieces of code which perform a specific function:
Function
(noun)
A function is a block of organized, reusable code that is used to perform a single, related action.
Using a stateless architecture has many benefits, but generally speaking a stateless architecture equals less complexity. For more details on this, see this blog post by Gareth Dwyer.
The three main cloud providers all have their own FaaS services:
They all offer a very similar service. If the developers function is part of a wider solution, deciding which vendor to go with will primarily be based on where the remainder of the architecture is hosted. Other than that, most people will simply choose the cloud provider they're most comfortable with using.
The short answer is that it sits somewhere on the scale between PaaS and SaaS.
The scaling of the containers used with FaaS is entirely taken care of by the cloud provider, and compute power is determined on a per execution basis. When the function is not being executed, there is no compute instance. This ultimately gives more responsibility to the cloud provider compared to when using PaaS, where the developer would be responsible for determining compute requirements and configuring scaling rules.
However, the developer still has full control over the application and function code. This gives more control to the developer compared to when using SaaS, where most application development has been done already and the developer essentially becomes an end user.
As mentioned previously, FaaS uses containers to execute functions. Containers themselves are not inherently serverless; using a container service such as Azure Container Instances or Kubernetes means that the developer would still be responsible for configuring and maintaining the containers. FaaS provides a serverless service for the developer by ensuring that the cloud provider takes full responsibility for configuring and maintaining the containers that the functions are executed on.
We've already touched on a couple of benefits, but we'll set them out in detail here.
FaaS is great for executing smalls blocks of code designed to perform a specific action, when the developer is not concerned about the environment the code is being run in. It's cost effective, and all infrastructure and scaling configuration and maintenance is taken care of by the cloud provider.
However, be mindful that if you require your application to be stateful, use multiple runtime stacks, or have extremely low latency, FaaS may not be the correct solution.