Have you ever wondered why you should pay for your cloud VM (Virtual Machine) even when your server applications are not used? Cloud computing provides increased flexibility in IT operations, through reducing IT capital expenses and enabling pay-as-you-go models. However, cloud services are charged per hour or per VM, even when computing resources in the cloud data center are not practically used. For such cases a range of more cost-effective solutions has been recently introduced, based on a new paradigm, coined “Serverless computing”.
The term “Serverless computing” has been around since 2-3 years i.e. since the release of Amazon’s AWS Lamda serverless computing platform. The term ‘serverless’ can be quite misleading, since serverless computing does not mean running an application without servers. Rather, it is another form of cloud-based service delivery (i.e. similar to PaaS: Platform as a Service) where the cloud provider charges for services on the basis of the requests to execute a function, instead of conventional cloud measures such as charging per VM used or according to time. This holds the promise to reduce the costs of cloud service delivery by charging for actual usage rather than continuous use of cloud resources. The use of the function as a measure of execution and mode of service delivery is also the reason why serverless computing is sometimes characterized as function as a service (FaaS).
In several cases, FaaS is not used in stand-alone mode, but rather in conjunction with other cloud computing and programming paradigms, such as microservices. For example its quite common for web applications to have one of their parts running in the cloud as microservice and another in a serverless fashion. It’s also common to use serverless code in rich client applications (e.g., sophisticated “fat” web apps or mobile apps) in order to access databases and authentication services in the cloud. The latter, authentication services (such as for example the Auth0 single sign-on and token based authentication), are commonly provided as FaaS. Likewise, the serverless paradigm is used in cases where server-side logic runs in third-party managed, stateless, event triggered containers. In such cases delivering functions in an ad-hoc fashion and charging them per invocation is much more practical and cost effective than the conventional “always connected” cloud computing way. Along these general lines and principles, let’s see some practical use cases.
Practical Use Cases
- Serverless Web applications: Using FaaS the delivery of web sites can become more flexible and economical, as web site operators could pay only for the functions they use in addition to some fixed costs for cloud-based database connections and services.
- Event driven analytics: You can opt for the serverless model when you would like to selectively invoke some analytics services (e.g., towards analyzing some web or server logs). FaaS is a good idea when you want to do certain analysis only upon the occurrence of specific events rather than continuously and at regular intervals.
- Data transformation: When in need of data transformations for your application you can use a FaaS service, as and when they are needed. As a prominent example, whenever you need an ETL (Extract Transform Load) operation you can access it as a serverless service, rather than paying for a dedicated VM for this task.
- Report generation: In several cases there is a need for generating reports as part of accessing a cloud database services. This generation can be handled as a FaaS.
- Data processing in sensor applications: Several sensor applications are event driven and process notifications in cases where some phenomenon is detected (e.g., a temperature threshold is exceeded). The processing of such notifications can be implemented based on a FaaS invocation.
As evident from the above-listed use cases, FaaS is a good option for handling short running, stateless and event driven functionalities.
FaaS vs. PaaS
FaaS has a clear value proposition when the scaling of an application has to be done at the level of an individual function. This is probably the main differentiator between PaaS and FaaS, as both are cloud models providing scalability and pay-as-you-go characteristics. In general following are the differences between PaaS and FaaS:
- In PaaS one has to still pay for spare computing resources that are not used, as is the case with the hourly billing model used in Amazon EC2. On the other hand, the FaaS pricing model is based on used memory, number of requests and the execution duration of the target function.
- PaaS offerings are provided 24/7, while FaaS services are event driven, which makes them ideal for handling bursts in demand for the target serverless functions.
- Elasticity and scalability in FaaS is slightly different from PaaS, as the measure of scaling in FaaS is the number of parallel executions of the serverless function, rather than the time a VM is used.
FaaS Infrastructures
As already outlined, AWS Lambda is nowadays the most prominent FaaS infrastructure, which is actually considered almost synonymous to serverless computing. AWS Lambda enables the execution of functions, without any need for provisioning or managing servers. It therefore enables a model where there are no charges when the serverless code or function is not used. It provides continuous scaling of a FaaS application as triggers arrive in the cloud and workloads becomes larger. Furthermore, Lambda implements a FaaS oriented metering and charging mechanism, which charges users based on the number of times the code is triggered, while keeping track of use in a time granularity of 100ms.
FUNKTION, is a framework for lambda programming for the Kubernetes container orchestration system. It enables the development of functions in any programming language, while providing the means to access them over HTTP/HTTPS. Furthermore, it facilitates subscriptions to many different event sources (e.g., messaging systems, social media, databases) for FaaS programming.
Apart from Lambda, there is also the Fission framework, which enables the execution of serverless functions over Kubernetes. Using Fission, one can benefit from automated scaling and deployment of the FaaS paradigm. Functions can be instantly deployed using a single command and without any need to build containers and to manage registries.
Serverless computing is certainly a promising paradigm with clear added-value for event-driven applications. Nevertheless, it seems to be complementing, rather than completely replacing, conventional cloud computing models such as PaaS. Hence, FaaS is here to stay, but its level of adoption and overall acceptance remains to be seen.