7 Reasons to Go Serverless
Updated: Aug 7
Today businesses are building enterprise-grade applications faster than ever. They're getting digital products and services to market at record speed and cost. And they're doing it by going serverless.
The cost efficiency of serverless computing can be astonishing. When insurance company Liberty Mutual rewrote their traditional web application as a serverless application their maintenance costs went down from $50,000 per year to just $10 a year. That's a 99.98% cost saving.
What is serverless computing?
Despite the name, serverless doesn't mean no servers. It means you don’t have to think about servers or the process of scaling them.
In serverless architectures, a cloud provider like Microsoft or Amazon manages and maintains servers on your behalf. This can be extremely cost-effective and give you tremendous flexibility when developing business applications. This flexibility becomes clear when you understand what serverless applications really are.
Serverless applications are composed of small, short-lived functions that run in the cloud. These functions consist of pieces of code that perform a specific task and are connected together using event triggers.
For example, one function might be triggered when someone visits a particular website. Another may run when a new record is added to a database. Functions can be triggered on a time schedule and can communicate with each other. By piecing together and orchestrating functions using events you can build extremely powerful and scalable applications very quickly.
Evolution of cloud computing
Before taking a look at the benefits of going serverless it's useful to understand how cloud computing has evolved over the past decade or so.
The first cloud computing offering was called Infrastructure-as-a-Service (or IaaS). IaaS abstracted away physical hardware and networking using virtualisation. Virtualisation means being able to run two or more operating systems on one PC.
With the introduction of IaaS companies no longer needed to purchase, house and setup physical servers. Instead, they could just rent server space (or Virtual Machines) from a cloud provider.
Provisioning Virtual Machines ‘in the cloud’ is now as easy as clicking a few buttons (or running a few scripts). Experienced IT infrastructure staff, however, are needed for patching the operating systems and runtime software that run on the Virtual Machines. But the convenience of using virtual servers afforded companies with enormous flexibility when it came to designing and building business applications.
In IaaS, scaling and orchestrating Virtual Machines is left up to you. Despite this overhead, IaaS can be more cost-effective than running your own datacenter. For instance, when you no longer need a Virtual Machine you can simply deallocate it and stop paying for it. Conversely, if you need more servers you can just provision more. This gives you an agility that's not possible with physical datacenters.
Your agility can increase further by running your application in a container. A container is a software package that contains all the necessary code and dependencies needed to run an application. Containerised applications can be run on any host or cloud-provider that offers a Container-as-a-Service (CaaS) platform. Containers therefore enable truly 'multi-cloud' deployments.
But there's a trade off as with such flexibility comes great complexity. As with IaaS, it's up to you (or rather software that you manage) to orchestrate the scaling of the Virtual Machines. The most popular container orchestration software is Kubernetes and it comes with a steep learning curve. Containers add such complexity to the development and deployment process that they require a specialised and experienced (and therefore expensive) team.
A more abstracted way of building and running applications is to use Platform-as-a-Service or PaaS. PaaS abstracts away not only physical servers but also the operating system and runtime. You simply code your applications and deploy to a PaaS service in the cloud. The cloud provider takes care of the Virtual Machines and operating system patches for you.
The downside of PaaS though is that capacity planning and scaling is still up to you. While scaling decisions can be configured to happen automatically, they require careful planning and redundancy which can be expensive. You may end up paying for servers even if they're not being used.
Serverless to the rescue
Serverless computing is a cloud computing service where you don't have to worry about servers, Virtual Machines, patching, scaling or idle time. It is the highest abstraction from any infrastructure or scaling concerns.
And it comes with lots of other benefits too.
1. Faster time to market
Serverless applications tend to be low code solutions because there is very little infrastructure code to write. This means it's possible to get to market in a fraction of the time it takes using more traditional software development architectures.
Businesses that can quickly build and deliver applications in response to customer needs will build lasting success.
Serverless architectures are great for rapid prototyping, building Minimal Viable Products and delivering new features fast.
2. Significantly lower costs
Serverless can save you a lot of money because by default they use a pay-as-you-go pricing model. You only pay for the compute time you actually use.
Virtual Machines come at a fixed cost. Some of the time they might just be sitting there doing nothing so you’re paying for idle capacity. You might also be paying for redundant Virtual Machines 'just in case' you get a spike in demand and need to scale quickly. This is a common (and very expensive) architecture used by many enterprise companies.
Serverless, however, turns your fixed costs into variable costs so you do need to be careful. If you get an unexpected increase in demand one month you might end up paying more than you budgeted for. But to manage this risk the best cloud providers allow you to set a limit on monthly expenditure.
As well as reducing hosting costs you can potentially save on staff costs too. Serverless computing can be managed by developers so there’s a reduced need for a dedicated DevOps team.
3. Easy to scale
If you go serverless, you don’t need to worry about scaling. The cloud provider handles that for you.
Serverless architectures encourage developers to split applications into independent functions. This means applications naturally evolve into microservices (or even nanoservices). By going serverless you're getting the benefits of microservices but with a reduced management overhead because you don't need to configure and manage any container orchestration software.
One of the core principles and benefits of microservices is that it allows you to scale parts of your application independently. This benefit comes 'out of the box' with serverless architectures as the cloud provider takes care of scaling for you.
4. Reduced complexity
Breaking apart a complex, monolithic application can be hard. But serverless computing can help simplify such an application.
By refactoring parts of your legacy application into serverless functions you can isolate complex, resource intensive parts of your codebase so they can be scaled independently and automatically.
Not all of your application needs to be (or should be) serverless. When deciding which parts of your application should be serverless, a simple rule of thumb to use is this: if it involves events it can probably be enhanced by serverless computing.
An event is a notification that something has happened - like a customer has ordered a product or a message has been received or a record in a database has changed. Because serverless architectures work well with event-based systems they're great for building workflows.
5. Minimal administration
As there's no server provisioning, patching, or scaling, serverless architectures mean developers can focus on writing business logic code. They don't need to worry about writing infrastructure code. This can dramatically reduce the size and complexity of your codebase.
The only administration required is deployment and most cloud vendors have created tools to make this very easy.
6. Extremely flexible
Serverless architectures are a great option for startups and for building MVPs. Small teams can roll out features quickly and easily. If and when it’s time to pivot, you can simply delete some of your serverless functions and deploy new ones.
New features are easy to add because serverless applications are loosely coupled by default. This could make estimating timescales easier as serverless applications are composed of small, discrete units of functionality.
7. Better development experience
Serverless functions are easier to understand and use than containers. So there are lower barriers to entry meaning your existing developers can get up-to-speed quickly.
Again many of the benefits of microservices architectures apply to serverless architectures. For example, developers can use different programming languages across serverless functions - although some governance is advisable here.
Reasons not to go serverless
As with any technology or methodology there are some downsides to going serverless. But these can usually be architected around. However, some applications, especially those that require more control over the configuration of the infrastructure, just aren't well-suited to serverless. In these cases, alternative technologies (such as IaaS or CaaS) should be used.
1. Not for long-running applications
Cloud providers restrict the amount of time that a serverless function can run. In Microsoft Azure for instance, functions are restricted to run for a maximum of 10 minutes on the Consumption (pay-as-you-go) plan.
It's possible to run Azure Functions on another plan that doesn’t have this restriction. But it comes at a cost. It may be cheaper to look at non-serverless options for hosting but this really depends on the specific use and should be determined on a case by case basis.
2. Vendor lock in
Some users worry about vendor lock in with serverless architectures. But many of the large cloud providers now allow serverless functions to be run in containers. This is a powerful cloud platform feature that will become increasingly popular. It comes at a cost though: increased complexity and administration.
You might be wondering why should you run your serverless functions in containers. Containers, you may recall, allow applications to run on any machine that has the right software installed. This means serverless functions can be multi-cloud so you can design your serverless architecture in such a way that avoids vendor lock in.
Quite often vendors will run serverless functions on the same Virtual Machine as other customers. Even though individual serverless functions are completely isolated from one another, this might be a concern for some companies in highly-regulated industries.
But attitudes are changing. For instance, the National Australia Bank, have seen some exciting benefits of going serverless. And the benefits aren't just financial - the improvement in resilience of their platform has had a positive impact on their customers.
4. Cold starts
If a serverless function hasn’t been triggered for a certain amount of time, the cloud vendor deprovisions the container that it’s running in. This creates a short latency when, after being triggered again, the cloud vendor has to spin up a new instance of the function.
The latency might be negligible but for more complex functions can be as much as 10 seconds. This isn’t always a problem but it’s definitely worth taking into account when designing serverless systems.
Bear in mind, however, that you can usually architect around this problem, for example by writing light-weight code. You can also use a dedicated service plan but you'd lose the cost-effectiveness of a pay-as-you-go plan.
Serverless architectures provide some amazing benefits that can save you a significant amount of time, effort and money. They make creating scalable, resilient and maintainable applications much easier than traditional ways of writing applications.
But they involve some trade-offs. Going serverless gives you incredible flexibility and agility but only if it's right for your project and use case. Even if an application isn't well-suited for serverless it's usually the case that part of it can benefit from some serverless features.
If you want to find out if a serverless approach would work for you, get in touch for a free consultation.