Lately, there has been a lot of talk about “serverless hosting” and “serverless architecture”. But, what does “serverless” mean and why should you care? In this post, we are going to explore the rise of serverless hosting, the benefits, and when you should consider going serverless.
First, let’s start with the definition of serverless hosting and how it differs from traditional hosting.
Traditional vs. Serverless Hosting
In traditional cloud hosting, users pay for compute and storage resources from vendors like Amazon Web Services or Google Cloud Platform. Websites and web applications run on these servers, that are managed and maintained by someone else. In effect, an organization “rents” resources from a vendor that manages a large pool of resources.
Serverless hosting is the next step in the evolution of the cloud. Instead of renting hardware by the day or the hour, serverless allows you to pay by the millisecond. In a serverless architecture, the fundamental unit is a function, as opposed to a server or resource. For example, let’s take a user pushing a button in a smart home app.
Traditionally, you needed to have servers running in order to understand and process the request that a user made (e.g., the mobile app had to be connected to a persistent back-end). By contrast, this new model means that pushing a button in a mobile app triggers a function to be fired off that completes a set of actions, say, turns on the lights or adjusts the music volume.
Functions can also be used to streamline or automate internal processes. A developer may want to send an SMS alert once application performance starts to degrade or storage capacity is reaching its limit. In this case, code for the function would sit idle until a predetermined threshold is met. Once the threshold is met, the SMS message would be sent.
As a business, you only pay for the time that your function is running. If nobody makes a request that triggers that function today, you pay nothing.
Serverless hosting: A fully managed service where individual the server management is invisible to the end user, thus the name “serverless”. Yes, servers are still involved!
Previously, companies had to buy and maintain their own server and database infrastructure. With the rise of cloud computing, you could effectively outsource this responsibility to a cloud vendor. And, with serverless computing, you manage even less. An individual developer no longer needs to remember an IP address, because even the running and scaling of functions is handled by your cloud provider.
Said differently, in the cloud world, you have to worry about your application and the development operations (DevOps). With serverless, you only have to worry about your application. Everything from network resources to individual server management is handled by the Googles and Amazons of the world.
Benefits of Serverless Hosting
Benefit 1: Pay for What You Use
In the world of serverless, payment happens at the level of individual HTTP calls. As a business, this means that you do not have to pay for idle compute or storage resources. In addition, transitioning to a serverless architecture means that you pay nothing when your function is not running – something that is not true in the traditional cloud computing model.
For Google Cloud Platform, the first 2 million calls are free. Users are then charged 40 cents per 1 million calls. This is different than traditional cloud computing, where users pay by the hour. For many applications, transitioning part or the entire application to a serverless architecture can result in a dramatic cost savings.
Benefit 2: Handle Specific Jobs
Functions are a new tool for developers, and many have started to build and share novel use cases. As mentioned, serverless functions work great for jobs that depend on the status of another resource. More specifically, jobs done in set intervals (e.g., run this report once every 30 days) or when a threshold is met (e.g., when database capacity is at 90%) are well-suited to functions.
Modern Functions as a Service (FaaS) infrastructure also works great for fetching static content. For instance, you can write a function that grabs text and image content from a repository when users access a blog post. No matter how much traffic you get, you can be sure that users will get the correct content each and every time, without needing to monitor or optimize server loads.
Benefit 3: Scale Infinitely
Just a few years ago, scaling an application proved to be problematic. As web properties grow, their resources needs do not scale linearly. For example, some portions of a website or web application may face constant interactions with others do not.
Appropriately scaling and managing resources was a painful task when each company was required to purchase servers. The transition to cloud computing made it much easier to provision and scale applications. Serverless provides an additional layer of benefits on top of cloud computing itself.
Because the individual business manages even less of the technology stack, scaling can now happen dynamically. Because each function is shut down once its run, there is no “permanence” to applications. Instead, numerous functions can run in parallel. Those that are highly active run all the time, those that are more infrequent run only occasionally.
With serverless, this scaling happens automatically. (As long as you can keep paying for it!)
Benefit 4: Reduced Threat Area
As a direct result of having less to manage, serverless reduces the threat area for a given application. In the world of serverless, businesses only need to manage their application code. Everything “underneath” your application code – including the dependencies, runtime, operating system – are managed by your cloud provider.
Companies also benefit from the security features that Google, Microsoft, and Amazon have built in. For instance, Google Cloud Platform allows you to set a maximum number of concurrent instances for each of your functions – allowing you to stop a denial of service (DoS) attack from happening.
Furthermore, major cloud providers have the resources to pay for physical security and experienced operations who can work around the clock to ensure that their infrastructure is secure. Said differently, small businesses and startups get access to the same high standards that government agencies and Fortune 500 corporations expect from the cloud giants.
Drawbacks of serverless hosting
The transition to serverless has many of the same considerations as going from a monolith to a microservices architecture. To get the full benefit of serverless, a rewrite of your application is often needed. We recommend starting by making the most relevant parts of your app serverless – like an infrequent service or one that has a highly variable load.
In addition to rewriting your application, businesses should be aware of vendor lock-in. Cloud vendors have built an effective suite of developers tools, but they also have an incentive to keep you on their platform. As of today, you cannot take from one service and run them on another. Some time and resources must be spent fitting a function to its new cloud environment.
Furthermore, functions require a new way of thinking for the fundamentals of application development. Developers are familiar with building, testing, and monitoring traditional app performance. But functions are event-driven (e.g., stateless), which adds complexity to monitoring and observability.
When Should You Go Serverless?
As with all new technology, it is important to understand the full set of business benefits and drawbacks. Serverless architectures are an exciting new tool to add to your digital arsenal, but they should not replace all of your other tools. Businesses developing new applications should consider how serverless can benefit their app.
Existing applications should be reviewed to understand how much cost-savings can be incurred by moving certain functions or services to a serverless architecture. Because existing apps will require an investment rewriting existing functionality, we recommend comparing the benefits and potential cost savings against the time investment of going serverless.
Functions as a Service (FaaS) is an exciting development that your development team should seriously consider. That said, be wary of trying to turn every single thing into a function. Despite what you hear, Functions are not the end-all-be-all of software development!
The Tragic Media team recommends learning early and implementing slowly.
In practice, you should start by understanding how this new architecture can benefit your organization, both in raw cost savings as well as resource savings. From there, you can create an informed plan of action. Once implementation begins, be sure to monitor progress and performance, adjusting your plan as needed.
While it can be exciting to jump headfirst into the future, we recommend a more balanced and pragmatic approach: Implementing and scaling new technologies on an iterative basis as they become more stable and as budgets become available.
Serverless technology is an exciting new tool to add to a software developer’s toolkit. That said, we do not recommend turning everything into a function.
As mentioned, we recommend to start leveraging serverless architecture on infrequent services, ones with highly variable loads, and ones that run based on a time- or resource-based capacity. Moving these services to serverless will have the biggest impact and lowest time investment.
Looking to evaluate serverless? Tragic Media is a software development company focused on bringing cutting-edge technologies and world-class user experiences to our clients. Contact us today to discuss going serverless!