Serverless Computing: Functions as a Service

Virtualization and containers have changed the way we run code. "Serverless" is the next logical step in that evolution - running logic without worrying about the environment or administration.

Technologies such as virtualization and containers have greatly changed the methods used to deploy software. When combined with DevOps practices, these technologies increasingly empower developers to build sophisticated systems without the need to worry about the provision of computing resources. This model is called cloud computing.

The evolution of "the cloud" has been towards greater abstraction. The job of systems administration is increasingly outsourced to a cloud provider, and the software developer is freed to focus exclusively on the application or program logic. Or at least, this is the sales pitch. The logical endpoint of this model is towards a fully abstracted system, where it is possible to run program logic without worrying about the systems on which it executes or how it is provisioned.

Many cloud providers are now beginning to offer services that allow exactly this type of model. Commonly called "serverless" or "Functions as a Service (FaaS)," such systems provide many important benefits. These include:

  • Complete Platform Abstraction: The "cloud" manages all infrastructure, components, and deployment.
  • Highly Scalable Performance: The most common platforms scale the application in response to program events and provide sufficient resources for required actions without requiring a developer or administrator to plan for the load.
  • Pay As You Go: Because of the way in which the application executes and scales, most services allow for sub-second billing. AWS Lambda, one of the most popular platforms, tracks consumption multiple times per second. Since most computing resources are frequently idle, even in cloud environments, it is possible to have enormous savings after migrating to serverless platforms. Some companies, such as Financial Engines, have reported cost savings of more than 90% by adopting serverless platforms in their infrastructure.

In this article, we will take a closer look at serverless computing. We'll dig further into how it works, the types of workloads and use-cases it works well for, available platforms (with a special emphasis on those which are open source), and a few of its limitations.

Defining Serverless

Upon beginning any discussion about Serverless computing, you quickly arrive at an important point: Serverless actually covers a range of techniques and technologies. Two of the most common include:

  • Backend as a Service (BaaS). Backend as a service are software components that are fully managed by a provider and can be integrated into an application. These include things that manage data, such as Google's Firebase, a popular database that is used by developers writing single-page applications or mobile apps, or security.
  • Functions as a Service (Faas) or Serverless Compute. FaaS (as noted earlier) is a generic environment in which minimally packaged applications can be run without worrying about the provision and deployment of resources. FaaS environments expose an application programming interface (API) which allows developers to create functions that can respond to events. The cloud environment then handles the provision of function instances in response to those events. When the function has completed its execution, the cloud will tear it down.

Of the two techniques, FaaS has received most of the attention and is, in fact, where a lot of the buzz about Serverless comes from. While many discussions treat FaaS and Serverless as synonymous (and this article will focus mostly on Faas), that is only part of the picture.

FaaS has become extremely popular amongst developers because it utilizes event-driven architectures with which they are already comfortable and minimizes deployment headaches such as implementing, configuring, or scaling a server. An additional benefit is that Serverless architectures can be configured to automatically scale with an application's needs. During periods of high demand, the system can burst to cover the capacity required and then idle back to effectively zero.

Related Components

Because FaaS is inherently event-driven, there is often more to a platform than an environment to host and execute code. Alongside this, there will be a set of sources to execute synchronous and asynchronous events. An example of synchronous events might include an HTTP API Gateway while asynchronous sources might include a message bus (such as Apache Kafka), an object storage (such as Amazon S3 or Minio), or a scheduled event similar to cron. As of this writing, Amazon Lambda incorporates more than twenty types of event sources.

Data Processing with Serverless

Because of its event driven nature and strong integration with message hubs and web API gateways, serverless has become popular for code that needs to respond to changes in upstream state. These include workflows that might be triggered by a signal, a file-upload, or a server request. This makes it especially well attuned for building data processing systems and pipelines.

Real-Time Event Processing

Serverless platforms can process data immediately after it is uploaded and automatically apply encoding and configurations to the data which makes them ideal for real-time event processing. For example, serverless platforms can transcode videos, index files, validate content, and aggregate filter data in real-time. This is to ensure that your deployed services are processing information effectively as they obtain their input data.

Many Serverless platforms include monitoring services that can process real-time streaming data for application activity tracking. Such monitoring features allow users to track their application's processes such as log processing, item indexing, metrics generation, data cleansing, metering, and media analysis.

Extract, Transform, Load (ETL) Workloads and Data Pipelines

A common challenge in many organizations is to build pipelines capable of handling data extraction, transformation, and persistence (load). Due to their architecture and event-driven nature, Serverless is ideal for ETL workflows.

Using Serverless, all incoming data for a pipeline can be validated, filtered, sorted, or transformed in an easy to understand component. The results from one step can then be piped to the next or uploaded to a secondary store for consumption by related applications.

Most cloud providers provide sophisticated interfaces for composing pipelines together, allowing granular management of data and its flow.

Web and Mobile App Backends / Internet of Things

Due to its elastic nature and event driven architecture, Serverless is ideal to handle the backend for web and mobile apps. API requests of all kinds of applications including web, mobile, Internet of Things (IoT), and 3rd party services can be funneled to specific functions that process the data, interface with other components, and return a response.

Many platforms provide ready-made API gateways and event sources that can authenticate and provide granular authorization of specific resources. These integrations greatly reduce the application complexity and make it possible to build systems that can scale up and down in an automated and consistent manner across multiple data centers quickly.

FaaS Landscape

Many cloud and application providers provide mature solutions for building and deploying functions.

In a 2017 report, the research firm Gartner identified more than fifty solutions within the FaaS ecosystem, underscoring the tremendous interest in Serverless technology. While the vast majority are open source and extensions of existing businesses, like Platform9's Fission, there are also many stand-alone implementations that take advantage of technologies such as containers and Kubernetes. In this section, we look at some of the most popular platforms.

AWS Lambda
aws lambda
Google Cloud Functions
google cloud functions
Microsoft Azure Functions
microsoft azure functions logo
IBM Cloud Functions
IBM Serverless

AWS Lambda

AWS Lambda is Amazon's serverless web service that offers multi-language support including Node.js, Java, C#, and Python. Lambda comes as part of a large application ecosystem including systems like Dashbird and Cloudwatch which provide real-time monitoring for the associated infrastructure.

Overview

Getting Started

Quickstart Example

Square Enix Logo

Case Study: Square Enix

Hosting a massive multiplayer online role-playing game, Square Enix had issues with image processing that would badly hurt the game's performance as more users joined in the game. It wasn't possible to keep up with the users' requests as the numbers grew, which prompted a switch to AWS Lambda for its elastic scaling capabilities. Almost immediately, the bottlenecks were resolved.

AWS Lambda had a critical impact - image processing that used to take hours was finished in seconds. Additionally, Square Enix was able to increase the efficiency of their infrastructure. The costs of hosting the servers dropped to one-twentieth of the previous expense. AWS Lambda provides an inexpensive solution to power your application without worrying about running out of computing power.

Google Cloud Functions

Google Cloud Functions is Google's approach to provide a FaaS platform for users. Google Cloud Functions is one of the newest additions to the cloud landscape and supports functions written in Node.js, Python, and Go. Like Lambda, Google Cloud Functions exists as part of a large ecosystem and includes tools such as Stackdriver (Google's monitoring system).

Overview

Getting Started

Quickstart Example

KNative Logo

Knative

Knative is a Kubernetes-based platform to manage modern serverless workloads. Knative comes from work done by Google in the creation of Google Cloud Functions. Its primary goal is to provide a developer-friendly interface for Kubernetes serverless.

The goal is to abstract the complexity that often accompanies Kubernetes and allows developers to focus on the important aspects of their applications. To this end, Knative provides gateways and other eventing systems that remove the "boring and difficult" parts of managing a cloud service, such as general, load balancing, authentication/authorization, etc.

Twitter Logo

Case Study: Twitter

Twitter is a social media platform with the goal of keeping everyone in the world informed about anything at any time. Twitter formerly used its own data centers for the platform's infrastructure but found this to be very expensive given the enormous size of its data set: 300 to 500 petabytes.

Twitter switched to Google Cloud Functions as the provider of its infrastructure. This switch increased the platform's performance, while also decreasing overall cost.

Microsoft Azure Functions

Microsoft Azure Functions is Microsoft's serverless computing platform. It supports common .NET languages like Node.js, C#, F# in addition to open languages such as Python, PHP, and Java. In addition to the established languages supported by Azure, it also provides support for specialized languages, such as a system that allows for the execution of batch files. Azure Application Insights is the built-in monitoring system.

Overview

Getting Started

Quickstart Example

HP Logo

Case Study: HP Inc.

HP is one of the most recognizable companies working in the tech industry. It has a very large product portfolio and deals with hundreds of tens of millions of support contracts each year.

"HP handles more than 600 million technical support contacts each year, and the company strives to make every single one a satisfying experience for the customer." Microsoft

As a solution to handle customer engagements while maintaining a high quality support experience, HP went to Microsoft Azure to handle the workload of virtual agents that are powered by artificial intelligence. HP has transformed its customer service experience by having virtual agents handle many customer contacts. This allows their customer agents to focus on more difficult cases and provide greater attention to their assignments.

IBM Cloud Functions

IBM Cloud Functions is a FaaS programming platform that is based on Apache OpenWhisk. It supports languages like Node.js, Swift, Java, PHP, Go, and Python. Additional languages can also be integrated through the use of containers. The monitoring and user interface for OpenWhish is provided by Cognos Dashboard.

Overview

Getting Started

Quickstart Example

SiteSprint Logo

Case Study: SiteSpirit

SiteSpirit hosts an online serverless media-library-as-a-service platform. OpenWhish allowed SiteSpirit to implement features allowing marketers to "find their picture-perfect marketing material in an instant".

The platform hosts a large media library that automatically tags, stores, retrieves, and manipulates thousands of images. Many of the annotation, recommendation, and transform work is handled by IBM Cloud Functions. Despite handling an enormous amount of ETL, the IBM Cloud Functions architecture is efficient and low-cost.

Benefits and Tradeoffs

FaaS Pros

  • Server infrastructure management can be avoided and developers are freed from needs to manage infrastructure. This allows them to instead focus on application logic.
  • Improved time management and more rapid delivery of new features.
  • Scalability: instead of scaling the application as a whole, you can scale each function automatically and independently. When not actively processing data, functions scale to zero.
  • Because of the ability to scale to zero, overall costs are reduced (often significantly).

FaaS Cons

  • Debugging issues - if a platform issue arises, it often becomes difficult to debug outages or downtime. Communication with the cloud provider often needs to happen, increasing the complexity of troubleshooting.
  • Not all workloads can be directly transformed into a function. Complex interactions or systems that require direct connection to a client are not easily transformed into a function.
  • As the number of functions increases, it can become difficult to track and monitor all of them.

OpenFaaS

A free and open-source FaaS platform.

OpenFaas is an open-source FaaS platform built on top of containers. Built with the goal of simplifying the deployment of event-driven functions and microservices on top of Docker and Kubernetes, the framework provides a software stack to build robust serverless systems. Like Kubernetes, OpenFaas is free and not tied to any specific cloud provider. This means that it can be deployed into a number of cloud environments and allows for a self-hosted FaaS solution.

OpenFaas Benefits

Portability

You can run your functions on any public or private server. Portability allows for the functions to be executed from anywhere no matter which operating system you are running.

All Languages Supported

Since it is built on top of container runtimes, OpenFaaS functions can be implemented in nearly any programming language. You can build microservices and functions in any language, and incorporate including legacy code and binaries as needed.

Scalable

Auto-scaling features are available to scale up and down in response to demand (just as with the platforms provided by the cloud providers).

OpenFaaS Cloud Native Stack

OpenFaaS utilizes Kubernetes and Docker for its runtime. Tooling which reads YAML files are used to package and deploy function templates. Supporting components include:

  • Docker: containerizes the application functions and provides the mechanism by which they are deployed.
  • API Gateway: provides an entry point to functions.
  • Function Watchdog: embedded in any container, provides the runtime element that allows container based functions to start.
  • Prometheus: provides monitoring capabilities to collects statistics of the system. System wide stats are collected by communicating with supporting infrastructures such as Docker Swarm or the Kubernetes API.

FaaS for Containers

Through the use of Docker, OpenFaas allows your functions to be built with any programming language. Machine learning, batch jobs, image/video conversion/IoT, and chatbots are all serverless use cases. Anything can run as a serverless function as long as it can be containerized. For this reason, OpenFaas often bills itself as a "Containers as functions" platform.

OpenFaas Highlights

  • Simple user-interface display portal
  • Write functions in any language that can be packaged in Docker image format
  • Portable in order to run onsite hardware or public/private cloud servers (Kubernetes and Docker Swarm native)
  • Command-line interface (CLI) and YAML format for templates and defining functions
  • Auto-scaling of resources as demand increases/decreases
Open-source Tools/Libraries for FaaS

Summary

Serverless is the next evolution of cloud computing. It provides a pattern for packaging logic while completely abstracting away the underlying environment and administration. This provides beneficial features including on-demand resource scaling and automated infrastructure management, improved efficiency, and pay as you go pricing.

Many providers offer great platforms to host functions in a cloud environment. Open-FaaS provides a free solution for teams who want to develop functions that are able to run in Kubernetes, enabling cross-cloud or self-hosted deployments.

While powerful with many practical benefits, Serverless really shines in data processing workflows such as real-time event processing, ETL, and web/mobile app backends.

Comments

Loading
Unable to retrieve data due to an error
Retry
No results found
Back to All Comments