The Advantage of Serverless Apps
Previously we have looked at the runtime characteristics of serverless apps, and also what use cases are good for (and bad for) serverless apps. This prior knowledge allows us to continue and talk about the advantages of writing (or rewriting) your apps as serverless. The advantage of serverless apps:
- Lower operational costs
- Faster performance
- Enhanced scalability
- Simplified operation
- More efficient maintenance
- Increased security
- Fewer dependencies, resulting in fewer bugs
For apps that do not need to run for long periods, the number one advantage is going to be cost. A traditional server (whether we’re talking about the hardware server or the software server) runs all the time. And cloud servers are billed by the hour, minute, or sometimes by the second. In systems like Kubernetes, the same software server may run on three or more different hardware servers, meaning you pay for not one, but three instances of your server. This can get very expensive, very fast.
In contrast, serverless apps run only when a request comes in. If your website is backed by serverless apps, there is no code running while no requests are coming into your website. During these times you’re not paying for anything. If requests spike for a few minutes, you’re only paying for those few minutes of load. This can be far more cost-effective for you. Cost is not the only advantage.
A serverless app is simpler, in that it does not need to handle multiple requests concurrently, and is often easier to debug. Even ultra-high-performance serverless apps can be built without complex multi-threading or concurrency, which means some of the most bug-intensive programming tasks can be avoided altogether. An example of this is the Fermyon Cloud application platform.
In Fermyon Cloud, a single app can be scaled from zero to tens of thousands of requests instantly, and there is no need for the developer to write any concurrency code at all! It’s the platform that scales up and down, not the individual serverless function.
Maintenance and operations time are thus both reduced as well. Since the platform itself manages all of the long-running bits and the developer is only responsible for the normal developer tasks, such as building, deploying and updating the application’s business logic.
Serverless apps also include added security advantages. Some of the most destructive and volatile security issues come from low-level parts of the application stack, such as networking, SSL/TLS, and process control. All of these are outside of the code that you write for a serverless app. So when that critical SSL vulnerability hits, your applications don’t need to be rewritten or even redeployed. The platform itself is all that needs updating. And with hosted ones such as AWS Lambda and Fermyon Cloud, that means you don’t have to do anything.
I once worked in an environment where we had over a thousand docker images, each running a full software server that included OpenSSL (a popular SSL library). When there was a bug in OpenSSL, the developer teams had to update every single one of those docker containers and then also redeploy all of them. Consider all of the team members in DevOps, Infrastructure Engineering, Cloud Engineering and so forth that had to be involved. Think of all the wasted hours!
As mentioned in a previous section, when we don’t need long-running processes, socket servers, protocol decoders, and concurrency to write our serverless apps, we vastly reduce the amount of code we need to write. We also reduce the number of dependencies we need to import. Less code results in fewer bugs, and more manageable maintenance.Browse Chapters