Serverless is definitely a buzzword in the tech industry now.
But what is Serverless? Is the Serverless hype justified? Is Serverless architecture really that good?
In this post, you’re going to learn what Serverless really is.
You’ll learn the basics of Serverless, deep dive on Serverless pros and cons, and find out what cloud providers (and frameworks) support Serverless architecture.
What Is Serverless?
Serverless (also known as Serverless Computing) is an execution model where the cloud provider (like AWS or Azure) is responsible for code execution — managing, provisioning, and maintaining servers to help developers deploy code in a continuous manner, with no friction involved.
But what about servers? Isn’t Serverless really server-less?
Well, not really.
- Pay for keeping up the servers that don’t serve any requests at the moment
- Maintain the servers, their uptime and resources
- Ensure server security and regular server updates
- Scale the servers up or down, based on usage
So, while the name is totally misleading, you don’t really have to keep the servers in mind when developing, updating, or supporting your software and applications. And this means fewer distractions, faster development time, and a considerable saving on resources that are dynamically allocated to run the code.
From a tech side of things, Serverless handles stateless containers, in which your code is packed; it can be manipulated through different requests or events coming in from your clients (e.g. a user pushes “buy” button). To ensure that a piece of code is properly executed, it should be sent to the cloud provider as a function.
Serverless: Microservices and FaaS
Serverless relies on functions. A lot.
To begin with, we need to understand the difference between a monolithic and microservices architecture.
Basically, monolithic apps are deployed as a single entity. In the meantime, microservices apps are broken down into smaller chunks, which are executed with no context about the server attached.
In Serverless, however, the apps are broken down into even smaller chunks called functions, which can run independently from each other inside stateless containers. That’s why Serverless is often called Function-as-a-Service (FaaS).
If you’re familiar with AWS Lambda, then you know what FaaS is and why it’s crucial to cut server costs and spare developers from dealing with storage and database capacity.
How Serverless Is Changing the Game
Serverless is the evolution of the cloud.
Here’s how Serverless is described by Werner Vogels, CTO at Amazon:
Before, your servers were like pets. If they became ill you had to nurture them back to health. Then with cloud they were cattle, you put them out to pasture and got yourself a new one. In Serverless there is no cattle, only your application. You don’t even have to think about nurturing back to health or getting new ones, all the execution is taken care of.
With Serverless, you enjoy flexible scaling and automated high availability, but don’t have to bear the burden of server management and idle capacity.
Let’s take capacity, for instance.
If you’re going to move to virtual servers in the cloud, it may take from a few seconds to several minutes. With Serverless, however, the process of provisioning servers goes away entirely.
But that’s only the beginning.
Serverless really changes the game in the areas of lower overall costs and reduced time-to-market, which are achieved through automation, parallelization, and faster development practices (like event-driven programming).
I’ll touch upon major pros and cons of Serverless a bit later, so let’s look into automation, parallelization, and development practices now.
Automation is the lifeblood of Serverless.
Unless your build and deployment process is automated, you won’t be able to fully utilize the power of Serverless. With automation not only your developers can deploy and test software in production-like environments, but spend more time delivering value to your business instead of redundant heavy-lifting.
To rip the benefits of automation with Serverless, you should:
Since Serverless solves the problem of over-provisioning, you don’t have to worry about paying for idle servers, or provisioning additional servers to complete high-volume, short-lived tasks.
Instead, you can scale your apps horizontally to parallelize your work. Just break down your computing tasks into multiple parallelized subtasks to complete them more quickly and efficiently.
Serverless has revolutionized the way developers manage environment and deployments.
In a Serverless architecture, your developers can take advantage of as many environments as they require. You don’t pay for idle, one way or another.
You can create independent demo environments for every single feature branch of your application.
Now, as your developers and QA engineers work on polishing specific app features and fixing bugs, you automatically get a deployed environment. New features can be immediately previewed and updates deployed from the branch.
To sum it up;
Serverless is a cloud execution model, in which you’re billed only for code execution time. If you need computing, you won’t spin up a server, but purchase computing from the cloud provider until the required functions are executed. It allows offloading redundant infrastructure tasks to the cloud provider while cutting operational costs and reducing time-to-market by relying heavily on automation, parallelization, and cost-efficient development practices.
Serverless Pros and Cons
The Benefits of Serverless
When we think about the benefits of Serverless, Amazon CTO Werner Vogels’ keynote at AWS re:Invent 2018 comes to mind. Specifically, here’s what he said:
The advantages [of Serverless] are obvious, there is nothing to provision, it scales automatically, it’s highly available and secure, and most importantly you only have to pay for what you use.
So, basically, Serverless rests on four pillars:
- No Server Management. You don’t have to worry about deploying and managing hosts. All server-related issues like OS configurations or runtime patching aren’t your concern.
- Flexible Scaling. The services scale up or down in response to the load, or based on the specified capacity of unit work. No longer you have to scale using such parameters as memory capacity or CPU cores. Instead, you specify the total amount of work that needs to be done.
- Automated High Availability & Fault Tolerance. An application’s deployments are distributed across multiple availability zones by default. Since a single point of failure is removed, your app becomes more fault tolerant.
- No Idle Capacity. You pay only for the total invocations of your function; plus, the time the function is running. If the function isn’t used, there won’t be any ongoing cost. Capacity management and elastic scaling aren’t your concerns now.
These four Serverless benefits naturally bring us to such perks as reduced infrastructure & operational costs, shorter time-to-market, better service stability, less waste, and increased flexibility.
Lower Overall Costs
Serverless allows you to reduce costs in three areas:
- Infrastructure. You enjoy reduced infrastructure costs, since you don’t pay for idle compute capacity.
- Operations. Your operational costs are reduced as well, since you no longer have to worry about server-related issues (like server provisioning and server security), fine tuning host configurations, creating machine images, and dealing with software deploys on specific servers.
- Engineering Resources. Since you offload a bunch of routine infrastructure tasks, you can focus your engineering resources on monitoring how your apps perform from a business-value perspective.
In a Serverless architecture, you don’t have to worry about infrastructure, setup, and capacity. And this means that you can focus entirely on product planning, application design, and the development process.
Serverless is increasingly flexible, and you can rapidly deploy highly scalable apps, as well as easily create simple prototypes to test specific functionality of your applications. This brings agility to the development process and allows you to roll out new features quickly.
Better Service Stability
Serverless makes your apps more stable and fault tolerant.
In a Serverless architecture, your app is broken down into multiple independent pieces called functions. In case anything goes wrong with a function, it gets reviewed and fixed while its previous version serves to plug the gap in a production environment. Once fixed, the function gets re-deployed automatically. So bugs are fixed more rapidly, and user experience doesn’t suffer.
On the contrary, monolith apps consist of big blocks, which are packed into a single block. Should any service crash, the entire monolith can crash, too. It’ll take you longer to find and fix the bug, and to deploy the block in production.
As Serverless is all about functions, it allows you to develop independent components that can be reused in similar products. For instance, you can develop payment processing once and then use it in other applications.
With that said, Serverless helps you save time and effort, specifically if you develop multiple applications.
Serverless makes your apps more flexible.
Should you need to change any feature, you’ll refactor it by tackling its specific function, and that’s it. No longer should you grind your way through by rewriting and testing your entire application.
The Drawbacks of Serverless
Up to now, we’ve been talking about how great Serverless is; yet, it’s time we realistically assessed and put forward its drawbacks, too.
Major limitations and disadvantages of Serverless:
- Vendor Lock-In. With Serverless, a third party provides the environment to run your apps. And this basically means that your app’s business logic is hooked to specific cloud-based services. Should you decide to move your app to another platform, multiple and painful fixes may be required.
- Reduced Control and Trust Issues. Serverless won’t give you as much control as you may get used to with open-source solutions. You should trust the cloud provider to share your app’s critical infrastructure and data.
- Security and Disaster Recovery Risks. By opting for Serverless, you entrust your application, including users’ private data to the cloud provider, which is risky and may not be the option for regulated businesses.
- Unpredictable Cost. Since you don’t know how many executions your application may to run (due to autoscaling), the cost of using Serverless can be hard to predict.
- Architectural Complexity. The learning curve for Serverless is pretty steep. You’ll have to deal with containers, microservices, and functions on the background of immature technology. Poor execution can result in component fragmentation, multi-tenancy, testing and monitoring issues.
- Cold Starts and Limited Execution Duration. A cold start is latency associated with bringing up a container to execute a function. In AWS Lambda, the cold start can be up to several seconds, which isn’t ideal for critical tasks that require higher availability.
- Lack of Tools. This one is subjective; yet, given that Serverless isn’t that mature, developers may find that it’s lacking in the tools department in comparison with other open-source and cloud offerings.
Given all of the above, it’s obvious may not be the option for long-running applications or applications that require a higher level of privacy. Architectural complexity coupled with technology immaturity mean that Serverless may become pretty complex to implement to achieve tangible results.
Major Cloud Services and Frameworks for Serverless
Cloud Services for Serverless
Serverless is supported by major cloud service providers: Amazon Web Services, Microsoft Azure, Google Cloud Platform, Alibaba, and IBM.
For sure, AWS is the leader of the Serverless movement. It released AWS Lambda back in 2014 and has been creating a fully functional Serverless ecosystem ever since.
Serverless on the AWS platform includes more than AWS Lambda, which is demonstrated in the image below:
In comparison, Azure Functions, Cloud Functions, and IBM Cloud Functions lag behind in the amount of Serverless tools. However, they have their own perks. For instance, Google Cloud Functions doesn’t set a limit for HTTP execution.
Kindly check out the slideshare below for more details about AWS, Azure, GCP, and IBM services for Serverless:
Other notable cloud services for Serverless are: Alibaba Function Compute, Iron Functions, Auth() Webtask, Oracle Fn Project, and Kubeless.
Serverless framework is a provider-agnostic platform that allows developers to work with Serverless in an agnostic environment. Serverless frameworks serve as infrastructure where Serverless Computing platforms can be executed.
Using Serverless frameworks, developers can deploy code on AWS Lambda, Azure Functions, Google Cloud Functions, IBM Cloud Functions, and other FaaS providers.
Other notable Serverless frameworks are: Apex, ClaudiaJS, Gordon, Spartan, Zappa, and Up.
Serverless is considered by many to be the future of cloud computing.
Due to its FaaS nature, Serverless can help you boost flexibility and reduce overall cloud costs. However, you’ll have to carefully design and manage your Serverless applications first, which isn’t easy to do because of a pretty steep learning curve.
Is Serverless worth the try, then? Absolutely!
Major cloud providers are pushing heavily to make their platforms more Serverless-oriented and to ease Serverless adoption by enterprises. The Function-as-Service market is projected to grow up to $7.72bn by 2021.
In other words, Serverless will continue to develop rapidly; and, if you’re going to strengthen your cloud computing skills, learning how to tackle Serverless is definitely recommended.