Hosting a website on a server can be like buying a crate for your new puppy. Sure, your puppy might fit now. But in a few months, you’ll be back at the pet store looking for the next size up. Depending on how fast your puppy grows, you might have to repeat this trip again. And again.
You might face similar issues with the server hosting your site. As your site grows, you’ll have to spend more and more time provisioning, managing, or upgrading your server to ensure your site keeps running smoothly. This will leave you less time to spend actually developing code.
What if, instead, you could focus solely on writing code and get someone else to handle the operational infrastructure of your site?
That’s the idea behind serverless functions.
In this post, we'll walk through what a serverless function is, how it differs from Functions-as-a-Service (FaaS), and some of the biggest names in the serverless architecture market.
What is a serverless function?
A serverless function is a programmatic function written by a software developer for a single purpose. It's then hosted and maintained on infrastructure by cloud computing companies. These companies take care of code maintenance and execution so that developers can deploy new code faster and easier.
Because these companies automatically add server capacity when you need it and then take it away when you don’t, you don’t have to worry about maintaining and scaling servers to fit the evolving needs of your website or application. Instead, you can concentrate on creating newer and better products in less time.
Going serverless can also be cost-effective since most platforms have a pay-as-you-go model. That means you only pay for the server resources you use, rather than having to eat the cost of unused resources at the end of your billing cycle.
Before we take a look at the major cloud providers in the serverless architecture market, let’s take a closer look at how you might already be benefitting from serverless functions.
Benefits of Serverless Functions
Many platforms have begun extrapolating smaller pieces of their back-end code and moving it to serverless functions. This marks a huge shift in the software development community.
Historically, platforms have been monolithic. Meaning, they had large, unified codebases. That meant any time you added a new feature, or even fixed a bug in a single line of code, you had to deploy the entire platform to ship the new code.
Then, microservices were introduced. Microservices are blocks of code that operate as smaller, individual services. Combined, they form a single, comprehensive application.
Serverless functions add another layer of modularity. With serverless functions, you can develop any new functionality or security patch as a completely isolated, single-purpose piece of code. All you have to do is upload your code and tell the platform how to provision it.
Serverless functions not only make the deployment of new code quicker, simpler, and easy to automate — they also significantly decrease the possibility of downtime during a deploy. In short, serverless functions improve the performance of your application and the experience of your developers and customers.
Recognizing the value not only to themselves but to their customers, content management systems like the CMS Hub Enterprise have begun offering serverless functions. This allows you to add interactive elements, like event registrations and dynamic calculators, to your HubSpot-hosted content without needing to configure an external server.
Imagine you’re a CMS Hub Enterprise user and run a fitness site. Using serverless functions, you can allow visitors to view upcoming classes and register for them (or sign up for a waitlist) directly on your site. You don’t have to manually keep track of sign-ups or set a class to full capacity or anything — just write the back-end code and set it up to be triggered when a visitor fills out a registration form. HubSpot will do the rest.
Before we take a look at other popular vendors, let's look at more examples of serverless functions.
Serverless Functions Examples
Below are case studies of brands using serverless functions to reduce costs and improve efficiency.
1. Walker Manufacturing
Walker Manufacturing uses serverless functions to collect, store, and dynamically display data from HubDB. This enables customers to select different options from a dropdown menu on product pages and view the most up-to-date details about that specific product, including images and pricing. This data dynamically displays without the web page reloading.
Here's a video that recaps how they use serverless functions and other features of CMS Hub to optimize their website.
2. Coca Cola
Coca-Cola uses serverless functions to reduce the costs of managing vending machines. When a beverage is purchased, the payment gateway makes a call to the AWS API Gateway. This triggers an AWS Lambda function to complete the transaction (which might include sending the customer a push notification on Apple or Android Pay if they initiated the transaction on their phone). Being able to pay per request instead of operating at full capacity enables Coca-Cola to stay on top of inventory while keeping costs low.
Here's an awesome illustration of the process below:
Using serverless functions, the ad-supported streaming service Kidoodle.TV was able to scale its video streaming by 3,200% in 2020. They use their own home-built ad decision service to decide which ads to display but deploy the code through the AWS Elemental MediaTailor ad decision server. That enables Kidoodle.TV to display the ads seamlessly so viewers don’t have to wait for the ads to load.
Before we move onto serverless architectures, we first have to clarify the difference between serverless functions and Functions-as-a-Service.
Function-as-a-Service, or FaaS, is a type of cloud-computing service that allows developers to write code as discrete functions that are executed in response to certain events, like an image upload or HTTP request. The cloud provider will either execute the function on a running server, or create a new server to do so.
Although serverless functions and FaaS are sometimes used interchangeably, FaaS is actually a subset of serverless functions.
Serverless functions can fall into to any service category where the configuration and management of servers are invisible to the end user. That includes storage, database, messaging, computing, API gateways, and more. FaaS, on the other hand, refers exclusively to event-driven computing wherein the code only runs in response to specific events or requests.
So, if you set a function to be automatically triggered by an event such as in-app activity, website clicks, or image uploads, you're using FaaS.
Now that we understand what a serverless function is, and what FaaS is specifically, let’s look at some public cloud hosting companies that have serverless platforms.
The global serverless architecture market is expected to be worth $25.49 billion by 2026, according to new report by Reports and Data. Below we’ll take a look at the serverless portfolios of some of the biggest vendors in the market.
Introduced in 2014, Lambda from Amazon Web Services is an event-driven, serverless computing platform that allows users to run code without provisioning or managing servers.
Users can run code for virtually any type of application or backend service with zero administration. Once they upload their code and set it up to automatically trigger from either other AWS services or directly from their website or mobile app, AWS Lambda takes care of everything required to run and scale the code with high availability.
Released in 2018, Google Cloud Functions is a serverless function environment on the Google Cloud Platform. As with AWS Lambda, users simply have to write their code and set it up to trigger from other Google Cloud Services or from their application. Google will handle the rest from there. This platform is ideal for setting up functions for data processing, like retrieving relevant data from images and videos.
Introduced in 2016, Azure Functions is the serverless computing service hosted on the Microsoft Azure public cloud. What sets Azure apart from the other platforms is that it provides an easy-to-use web interface where users can write code. Azure Functions is ideal for tasks like image processing, order processing, and file maintenance.
Released in 2019, IBM Cloud Functions is a FaaS programming platform based on Apache OpenWhisk that enables users to develop lightweight code that scalably executes on demand. IBM Cloud Functions is ideal for deploying serverless apps across multiple regions and building a serverless back end for a mobile application.
What’s unique about this serverless platform is that it can work in combination with other IBM solutions, like the IBM Watson IoT platform and IBM Event Streams, to react to and process IoT sensor data and incoming messages.
Introduced in 2017, Alibaba Cloud Function Compute is a serverless platform that provides the compute resources required to run code flexibly and reliably. This allows users to focus on writing and uploading code instead of having to manage servers and other infrastructure. Function Compute is designed to reduce computing costs and improve computing efficiency when building serverless web applications, processing data in real time, or creating AI reasoning services and serverless video processing systems.
Trying to decide whether serverless is right for you? Consider these reasons below.
1. You want to reduce server costs.
Going serverless will significantly reduce server costs. That's because cloud providers only charge for the time that serverless functions are running so you're not paying for unused resources.
2. You want to free up developer resources.
Since no one has to deal with infrastructure management when going serverless, developers and engineers can focus solely on building out new features and improving the product.
3. You want to scale your web application.
Switching to serverless can help your web application scale with no operational concerns. Bustle, for example, fully adopted a serverless architecture back in 2016 to better handle traffic spikes. This enabled Bustle to serve upwards of a billion requests to over 80 million people per month, according to cofounder Tyler Love.
Serverless is the future of software development. By using a platform that offers serverless functions like CMS Hub, you’ll reap the benefits of reduced server expenses, auto-scaling, and improved uptime.
Editor's note: This post was originally published in February 2020 and has been updated for comprehensiveness.
Originally published Oct 27, 2021 7:00:00 AM, updated October 27 2021