At first glance, it sounds impossible – how can any cloud-based architecture be serverless? But of course, the serverless in serverless architecture doesn’t really mean without servers. So what does it mean? Let’s dive in!
Serverless architecture is an approach to software development that allows developers to ignore considerations associated with the physical machines their code will be run on. Physical machines are still used, of course, but they are provisioned by a cloud provider in accordance with the in-the-moment requirements of the developer’s application.
Serverless architecture thus allows developers to focus on building the services that power their application, without having to worry about which physical hardware to choose, how and when to scale, how and when to maintain and upgrade their machines, etc. Instead, the cloud provider takes care of all of that.
Serverless architectures also typically offer a pay-for-what-you-use model, which is often cheaper than paying for a preset number of dedicated machines. For example, a developer who uploads a function to AWS Lambda will be billed based on how many times the function was run during the billing period.
Many elements of an application can now take advantage of serverless architectures.
One of the most common examples of serverless architecture is serverless functions (functions as a service, or FaaS). Cloud providers including AWS (AWS Lambda), Google (Google Cloud Functions), and Microsoft (Azure Functions) allow developers to upload specific application functions to the cloud, where the function will then be run when it is triggered (for example, by an API call).
Another common example is a serverless database such as CockroachDB Serverless. Developers can host a distributed SQL database with the cloud provider of their choice and it will scale automatically (within the developer’s set monthly spending limit) to meet demand.
Serverless architecture is often used in tandem with microservices architecture, as the two complement each other well. When an application is broken down into individual microservices, each of these can be hosted using a serverless architecture, allowing them to auto-scale individually, rather than having to scale all of the application’s resources up and down monolithically.
The advantages of using a serverless architecture can vary based on the application, the use case, and the cloud provider, but some of the most commonly-enjoyed benefits are:
Serverless architectures aren’t the best choice for every use case, however.
If you require detailed control over the machines your application is running on, either for performance or security reasons, serverless architecture may not be the best choice, since that work is offloaded to the cloud providers.
Serverless architectures aren’t always cheaper, either – there are certainly cases, particularly for larger enterprises, where dedicated machines can end up being the more affordable choice. Vendor lock-in with many serverless services can also be a problem that leads to increased costs.
Additionally, not all serverless platforms and cloud providers are created equal. Issues like slow cold starts can actually make your application’s performance worse, so it’s important to look at the details when it comes to choosing any sort of serverless provider.