pixstock - Fotolia
What the critics get wrong about serverless costs
While critics say serverless is an expensive, clunky way to deploy software, it really isn't -- if you use it right. Let's debunk some myths around the costs of using serverless.
If you read certain clickbait blog posts, you could be forgiven for thinking serverless is just another empty buzzword.
These posts provide a dismal view of serverless, especially when it comes to cost. They argue the pricing models are too complicated, or that it's slower and more expensive than VMs or that the promised simplicity actually makes things too complex. These bloggers see an incomplete, expensive, clunky and painful way to deploy software.
Some sites, such as this Banco Bilbao Vizcaya Argentaria (BBVA) blog, outline a fairer view of serverless costs, but they still tend to confuse readers. BBVA finds cases where serverless is more expensive than VMs, and others where it is less. Yet, the blog is still unhelpful, as it concludes, "Traffic distribution does have a considerable impact on break-even and thus, the cost."
In my experience overseeing more than $25 million in cloud spend over the past 12 years, serverless is almost always cheaper. In this piece, I'll go over some commonly asked questions and real-world examples to help you better understand what the naysayers miss about serverless costs.
How is serverless actually cheaper?
Before we dive into specifics, let's be clear about what we mean when we say serverless. Rob Sutter, a serverless developer advocate at AWS, describes serverless infrastructure as meeting four criteria:
- No infrastructure provisioning or management;
- Automatic scaling;
- Pay for value, not for hardware; and
- Highly available and secure, i.e., automated failover, backups and restores.
Granted, there are some cases where serverless will be more expensive. One example would be when you have existing cloud infrastructure, and there would be significant cost to migrate to a serverless architecture.
But by and large, when considering the total cost of deploying and running software, you save more money when you don't have to manage or pay for idle infrastructure, such as VMs or containers. And to the extent that serverless choices help you avoid writing and maintaining custom code, your savings will be even deeper.
Serverless costs example: Branch Insurance
Let's look at one specific example: Branch Insurance. At Branch, where I am CTO and co-founder, we run a full-stack insurance company where we sell home, auto, umbrella and renters insurance. We run all of our infrastructure in a serverless manner, and this is our cloud bill for our production environment for October 2020:
In October, we handled up to 50,000 active users a day, and we sold and serviced a lot of insurance policies. This bill includes all cloud infrastructure for purchase, service, filing claims and our mobile app. We spent no time or money on uptime, scaling, patching, maintenance or anything related to infrastructure operations. This is not to say there are no operations tasks in serverless, but they're significantly less than with other compute models.
We also provide every developer and environment with their -- or its -- own cloud account, with a complete replica of production. Since it's all pay-per-value, it's not expensive to replicate. The sum of our costs across all of those -- excluding the production environment above -- was around $500.
But what would our bill be for this same resilient, scalable infrastructure handling the same amount of traffic without using serverless infrastructure?
Well, our baseline costs would have been more than $5,000 a month for the types of VMs or containers we would have needed to take web requests and process them as quickly, especially to address scaling in times of high traffic. Additionally, we would have spent at least another $5,000 a month on highly available relational database and cache infrastructure.
But those aren't even the big expenses. We would have needed systems administration and operations expertise. We would have needed them to staff an on-call team to handle issues that happen outside of our code but within the cloud infrastructure we managed. That would run to tens of thousands of dollars more a month.
Why is serverless considered expensive again?
There are a few main areas where people misunderstand serverless costs.
They often exclude the total cost of running services on the web. This includes the personnel requirements and the direct payments to the cloud provider I just discussed. Other times, they build bad serverless architectures.
Serverless, like cloud, is not a panacea. It requires knowledge and experience about what works and what doesn't -- and why. If you use serverless correctly, it shifts significant costs to the cloud provider. They keep your services running, scaling up and down, and recovering from hardware, software and patching failures. Most companies that run mission-critical web applications and/or APIs have operations staff who do exactly this.
This is not to say that adopting serverless means putting people out of work. Charity Majors, co-founder and CTO of Honeycomb, wrote a great article on how operations jobs are changing rather than going away. But if you can hand off patching operating system and software vulnerabilities to a cloud provider, then the people on your staff who previously handled those tasks become available for more strategic and differentiated tasks for your organization.
There also seems to be a shocking number of people who try to build something with serverless without fully understanding the technology first. The piece we linked to earlier that claimed serverless is "slower and more expensive," actually includes a note at the end that it was 15% slower and eight times more expensive. But there's also a note at the bottom indicating that the author understands he didn't build the application correctly.
It's all reminiscent of the early articles about the cloud that would argue the public cloud is too risky and too expensive for big enterprises -- or basically everything Larry Ellison said about the cloud for nearly a decade.
Where do I start?
If you are considering building an application with a serverless architecture, I recommend digging into a few serverless resources first. Check out the serverless courses from Yan Cui, the Off-by-none serverless newsletter from Jeremy Daly, Nader Dabit's Full Stack Serverless, as well as the Architect and Serverless frameworks.
It is far better to spend two weeks researching and two days building than it is to spend two days researching and two building, especially with serverless.