You’re probably hearing more and more about serverless web applications recently. While some snarky people might say, “there are always servers somewhere” (and they’re right), that’s not the point.
Once upon a time, people had to raise animals and work the fields to get food; now, we go to the market (supermarket, farmer’s market, online market) to buy it.
So, what’s the point I’m trying to make? Humanity has become more advanced and managed to create technologies and processes (some good, some not as good) that bring down costs and make products and services available to a wider audience. The same has happened for the compute running your applications.
Think of it this way: When I started programming, just after the dial-up era (I know, I’m no spring chicken), I had to do the following:
- Rent a server in a datacenter
- Learn some commands in whatever the OS they were using
- Install your web server (usually Apache)
- Add your programming language of choice (Python, PHP, Java) and connect it to the web server
- Install your database (usually MySQL)
- Add some firewall rules
- Code your app
- Test it
- Upload the archive with your app and put the contents in the web server root folder
Coding the application was just like the cherry on top of the cake for most people – the only fun activity after all of the more mundane stuff. Remember?
That’s why shared hosting was such a big hit. Along with web management interfaces (cPanel), it automated a lot of the work for us, cost less, and included more features. A winning combination!
Shared Hosting & VPS
Unfortunately, noisy neighbors (when other apps use every resource on the server) and the availability of programs that let you flood websites and take them down, made us consider a middle ground: the VPS.
It was a decent compromise: you had reserved resources, plus root access so you could harden your server (yet another thing to do).
Things got better over the years, with all kinds of automation (Ansible, Puppet, Chef) promising to install and configure your servers quickly, and of course, containers helping different apps play nice on the same instance.
But there was still work to do, even if it was less work than before. What most people wanted was to focus on the code.
And that’s what serverless is all about.
You don’t have to configure, patch, harden, or manage servers, or even containers. Services such as AWS Lambda come with preconfigured environments (you can bring your own, as well) – just add your code. And if you want it to run faster, or lower costs, adjust the slider to find the right setting for you.
Serverless, let’s talk money!
On AWS Lambda, you’re charged for every 100ms of code running:
The CPU is allocated in direct proportion to the RAM value you set, so higher RAM provides more CPU power.
Now, let’s look at a pricing example from their website:
Running your code 30 million times costs the same as lunch in most cities.
But what’s that free tier thing? Well, AWS’ free tier offers a free quota of their services, some just for the first year and some forever.
The best part is that AWS’ free tier has everything you need to build serverless web applications: Lambda and DynamoDB (a NoSQL database) with a pretty generous offer that’s not limited to the first year.
This means that you can build serverless applications for yourself, your friends, or your community with running costs so low, it might even be FREE.
When is Serverless the Answer?
We must always ask ourselves if a new thing is actually useful, and if it is, in what scenario.
I’m especially suspicious of a technology that companies market as a solution for every use case (I could name a few right now).
The value of a technology doesn’t lie in its complexity or hype, but in what it allows us to build compared with the effort invested.
Serverless is right for you if you can use the Cloud and:
- Don’t want to spend effort in managing containers/servers
- Have irregular access patterns
- Work in a startup environment
- Just want to focus on the code
In terms of cost, scalability, and flexibility, serverless is currently the best choice for most use cases, if you can use a Cloud provider such as AWS.
In my latest webinar, you’ll learn how to build a serverless web application in Node.js using GraphQL and Amplify, which is listing jobs around the world and life quality metrics in those cities.
You can use the same technologies to build your own serverless application.
Check out the webinar recording.
Dive into my entire AWS webinar series to get a better understanding of what AWS can do for your:
If you have any questions what so ever, I will be more than happy to reply.