Being cost-efficient, minimizing the effort spent on keeping the infrastructure up and being able to deploy features quickly, independently, and without downtime is definitely the dream of every tech company.
This is where Serverless comes into play, having the provider which takes responsibility for receiving client requests and responding to them, capacity planning, task scheduling and operational monitoring, allowing the developers to focus their work on application-specific logic reducing the amount of time and effort required to implement and launch a new project or feature.
Major cloud service providers offer very competitive services when it comes to Serverless, especially when talking about FaaS ( Function as a Service):
- Google Cloud Functions
- AWS Lambda
- Azure Functions
- IBM OpenWhisk
Fundamentally, FaaS is about running backend code without managing your own servers, providing security, fail-over, load balancing, patching, operating system maintenance, and capacity provisioning.
There are also some architectural constraints in order to enable some of these benefits, especially when it comes to state and execution duration.
For example, the “timeout” for an AWS Lambda function to respond to an event is at most five minutes, which means that a function needs to be something that can start up and run quickly. They are created and destroyed based on the runtime need. When demand drops, the application automatically scales down.
Also, another limitations is that FaaS functions are stateless, meaning that any state of a function required to be persistent needs to be stored outside of the function instance (in a database, object store,etc.).
Pros of FaaS
- Time to market
You no longer need to spend a lot of time on managing servers, databases and even application logic, allowing you to focus on your product innovation and getting you modern applications in front of your customers as soon as possible and get early feedback.
2. Continuous experimentation
As we are driven by the Agile mindset and continuous adjustment to trends and new technologies, we need a way of experimenting new ideas and validating them quickly in order to take a decision for our business.
That`s why being able to create a small project/component and having it up and running in just a few hours is definitely a key driver for every company willing to continually try new things and rapidly improve, deploy or replace its existing systems at minimal cost.
3. Reduced development and operational cost
Beyond the technical convenience, because all your resources are manged by the provider, you don`t need to own and manage the hardware, networking, etc. paying only for the compute that you need.
Rather than continuously running servers, you are billed only when an application actively processes events, which means that application idle time is free.
Horizontal scaling is automatically managed by the provider.
Depending on your traffic scale you can respond to high demand quicker and handle the spikes better which means also that you only pay for the extra compute capacity during the spike phases.
Similarly, since scaling is performed by the provider on every request/event, you no longer need to think of how many concurrent requests you can handle before running out of memory or seeing too much of a performance hit.
5. Community Support
The Serverless community is growing very quickly, with multiple conferences, meetups, online groups, encouraging more and more people to take this technology into account when building the architecture of their next project.
Cons of FaaS
There’s certainly a lot of benefits using Serverless architectures, but there also at least 2 significant trade-offs which needs to be considered before starting a new project.
- Vendor control
You have no control over the resources your app is using, which means you can experience system downtime, cost changes, forced API upgrades, etc. It’s very likely that if you want to switch vendors, you’ll also need to change your code, design and architecture to satisfy a different FaaS interface.
The changes may be small, but they will still have an impact on your solution.
2. Architectural constraints
As I mentioned earlier FaaS functions are stateless, which means that you`ll have to add some more complexity and do some more extra work if you have some info that needs to be stored, even if it`s a very small amount of data you`ll still to use a database, an out-of-process cache, etc.
Also, the functions are aborted if they run for longer than five minutes, which means that each individual task needs to complete within that time frame.
If individual requests can be completed in a relatively short time window, then a serverless approach is a very good way of reducing hosting costs significantly, and to speed up the time to market for your projects and ideas.
But of course, this doesn`t mean that Serverless is the solution for every problem, for example if your traffic is uniform and would consistently make a good utilization of a full-time running server , then you may not see this cost benefit by using FaaS.
Therefore, everything depends on your business needs, the costs offered by the providers and on your architecture limits.