The Developer Space

Developer's Cafe

  • Cloud
  • Database
  • Open Source
  • Programming
  • Web Dev
  • Mobile
  • Security
  • QuickRef
  • Home
  • Architecture
  • Evaluating if Serverless is suitable for your needs – A comprehensive analysis

Evaluating if Serverless is suitable for your needs – A comprehensive analysis

Shameel Ahmed - Architecture, AWS, Azure, Cloud, GCP, Serverless
September 17, 2023September 17, 2023 No Comments
Serverless cloud serverless
7 0
Read Time11 Minute, 36 Second

Serverless model makes it easy to develop and deploy your applications and services in the cloud quickly. However, does that make it an ideal choice for all your needs? Amazon’s decision to move away from Serverless back to a monolith architecture for its Prime Video monitoring service has rekindled the discussion about whether serverless model is suited for all use cases. Learn when to use and when not to use serverless model in your projects.

Table of Contents

  • Serverless Basics
  • History of computing infrastructure and evolution of serverless
  • Cost Analysis
  • When to use serverless model
    • Variable Workloads
    • Event-driven Applications
    • Microservices
    • Rapid Development and Prototyping
    • Short-lived functions
  • When not to use serverless model
    • Steady or Predictable Workloads
    • Long running functions
    • Resource intensive tasks
    • Custom runtime environment or Non-standard Tech Stack
    • Stateful Functions
    • Large Data Transfers
  • The Amazon Prime case
  • A pragmatic approach to new development
  • Conclusion
  • References

Serverless Basics

Serverless is a computing model where you can build and run applications and services without the need to deploy your code on servers directly or to manage and monitor the availability and scalability of the application or service. In a serverless architecture, the cloud platform automatically handles server provisioning, scaling, and maintenance, allowing developers to focus solely on writing code and implementing business logic.

Contrary to its name, serverless is not really server-less. There are servers behind the scenes that execute your code, but you do not deal with them directly. AWS Lambda and Fargate are examples of serverless functions that abstract the underlying servers from your deployment and execution process.

History of computing infrastructure and evolution of serverless

From the early days of computing up until a decade-and-odd ago, hosting applications on bare-metal hardware aka servers was the only option available. This is the most inflexible and cumbersome option as every aspect of the infrastructure must be handled manually by the Dev/DevOps team.

Virtual Machines came into being to overcome the limiations of bare-metal approach, and they were used extensively to manually or semi-automatically (using scripts) scale-up and scale-down infrastructure in response to demand. VMs could be launched and terminated on-demand to meet the variable workloads. However, this approach was far from perfect as it suffered from lack of flexibility and dependency management issues. The Dev/DevOps team was still responsible for installing and configuring the dependencies in the individual VMs. Amazon Auto Scaling Groups overcomes these limiations by using an EC2 image and managing a pool of EC2 instances that are front-ended by Load Balancers to automatically scale-in and scale-out applications and services.

Containers started getting popular in the last decade since they offer a layer of abstraction on top of what VMs offer. Containers are self-contained pods that package an application or service and all of its dependencies into a single deployable image, which makes scaling applications up and down in response to demand, easy and quick. But the responsibility of packaging and deploying the application or service still rested with the Dev team or the DevOps team.

Serverless takes this a step further by completely abstracting how a particular piece of code is deployed and managed in the cloud, and makes irrelevant the question of “where” the application is hosted. This means that there is no infrastructure spin-up, and therefore no servers of VMs to manage.

Cost Analysis

Serverless is generally seen as a cost effective solution since it runs in Cloud and is billed only for its execution time. However, this is far from truth and serverless can end up being very expensive if not used correctly. This article lists all factors that needs to be considered before deciding to adopt serverless model for your needs.

Although Serverless sounds exciting and optimal, it is not suitable for all use cases. There are situations where embracing Serverless model is beneficial and where Serverless could prove to be counter-productive and expensive.

When to use serverless model

Variable Workloads

Serverless automatically scales-out and scales-in in response to demand which makes it an ideal solution for unpredictable workloads that can vary drastically throughout the day. Traditional or monolith solutions would result in higher infrastructure management and operational overhead in such cases. Serverless provides an efficient way to handle both low and high traffic periods.

Event-driven Applications

Serverless models excel in event-driven scenarios. Serverless is a natural fit for applications and services that rely heavily on events like user uploads, database changes, or API calls. Services like AWS Lambda, Azure Functions, and Google Cloud Functions are designed to respond to events instantly, making them perfect for tasks like image processing, data transformation, and real-time notifications.

Microservices

Serverless is an excellent choice for hosting Microservices. Each service can be implemented as a Serverless function or a set of serverless functions which ensures scalability and isolation, and also makes deployment easy.

Rapid Development and Prototyping

With Serverless, there is no infrastructure provisioning and no server deployment or configuration. It just works with the click of a button or with some basic Infrastructure As Code (IaC) scripts. This makes it an ideal candidate for prototyping and proof-of-concept (PoC) development. Quicker time to market ensures early failure detection and course correction which can be quite expensive and time consuming with traditional development approaches.

Short-lived functions

If your functions or tasks are designed to execute quickly within a few seconds, you would benefit greatly from Serverless model as it is optimized and well-suited for such functions. Moreover, the pay-per-second model ensures that you pay only for the time your functions execute and helps in keeping the cost low. Traditional approaches keep the servers at full capacity even when functions are short-lived, which is both inefficient and expensive.

When not to use serverless model

Steady or Predictable Workloads

Serverless is charged based on the execution time. Therefore, if your workload has steady/consistent usage or has variable usage that can be predicted by the time of the day or day of the week, it generally makes sense to go with monoliths or containers. They are cost-effective compared to serverless approach in fixed-workload situations.

This is exactly the reason Amazon Prime migrated its video monitoring service from serverless to monolith. More on this further down the article.

Long running functions

Serverless functions have execution limits and are generally not suited for long running tasks. Apart from being less optimal, they can also prove to be expensive in such situations. If you have long running tasks like data processing pipelines and data transfer modules, you should consider using container models or monoliths.

Resource intensive tasks

Tasks that require heavy resources like database connections, multiple network round-trips, multiple orchestrated API invocations, reading or writing large files, etc. are not suitable candidates for serverless functions from a cost perspective. The backend dependencies can slow down your functions which results in higher cost even when the functions are themselves idle and waiting for the backend information to arrive. These use cases are better suited for asynchronous/callback functions running on containers or virtual machines.

Custom runtime environment or Non-standard Tech Stack

Serverless functions like AWS Lambda and Azure Functions generally support standard technology stacks like Java, .NET and Python. They also support only standard libraries and packages. If your functions use non-standard tech stack or custom libraries or packages, then you cannot use serverless functions. Container applications with custom images will work better in such situations.

Stateful Functions

If your functions or tasks are stateful, i.e., they need to maintain state between subsequent invocations, it is difficult to achieve it using serverless model as serverless is optimized for short-lived and stateless tasks. Maintaining state across function invocations involves implementing a custom state management solution which can easily be achieved using container applications and monolith applications.

Large Data Transfers

If your requirement involves transferring large chunks of data between applications/services or between applications and databases within the cloud, or between cloud and the Internet, you should seriously consider keeping away from serverless model and embrace traditional approaches like containers and monoliths. Cloud providers typically charge for all kinds of data transfer between different components within the cloud or between cloud and the Internet. Specifically, data transfers across regions can be quite expensive.

The Amazon Prime case

A few months ago, Amazon had published an article that discusses how Prime Video addressed challenges related to scaling up its audio and video monitoring service while reducing costs by 90%. Initially, Prime Video employed a distributed serverless architecture but encountered scaling bottlenecks and high costs. To overcome these issues, their infrastructure was rearchitected into a monolith application, packing all components into a single process and eliminating the need for intermediate storage. This change significantly reduced infrastructure costs and improved scalability, allowing them to monitor thousands of streams effectively. The article emphasizes that the choice between microservices and monolith architecture should be made case by case. These changes ultimately resulted in higher quality monitoring for all customer streams, a better user experience and significant cost reductions.

A pragmatic approach to new development

If you are developing a new application/service and are unable to decide if Serverless is a right choice, then you can consider prototyping your application using Serverless model and then migrating to containers or monoliths later if needed.

  1. Serverless has zero infra setup and can get you started with development instantly.
  2. Serverless provides basic features like high-availability and security out-of-the-box, so you do not have to worry about implementing them manually.
  3. Serverless is production-ready from day one and can help you deploy your applications and services quickly and confidently to production.

If you decide to stay with Serverless, well and good. Moving to monoliths or containers later due to cost or other factors usually requires a complete re-architecture of your solution. However, the additional efforts can be justified by the savings in time and cost and the risks averted by opting for serverless in the beginning.

Conclusion

Serverless offers numerous advantages, such as scalability, cost-effectiveness, and rapid development, making it a compelling choice for many use cases. However, it’s crucial to assess your specific use case to determine whether serverless is the right fit. Consider factors like workload, execution time, and control over the environment when deciding whether to go with serverless or consider more traditional infrastructure solutions like monolith applications. The key is to choose the approach that aligns best with your application’s requirements and goals.

If you found this article useful and actionable, please leave a comment. If you have suggestions to improve the article, leave a comment.

References

https://www.primevideotech.com/video-streaming/scaling-up-the-prime-video-audio-video-monitoring-service-and-reducing-costs-by-90

Share

Facebook
Twitter
LinkedIn
Email

Post navigation

5 reasons you should switch from VS Code to VSCodium

Related Articles

Invoke OpenAI APIs from API Gateway

How to build a REST API using Amazon API Gateway to invoke OpenAI APIs

Shameel Ahmed
March 11, 2023March 11, 2023 1 Comment

How to fix “‘StreamingBody’ object is not subscriptable” in AWS Lambda boto3

Shameel Ahmed
February 12, 2023February 12, 2023 No Comments
Migrate your SQL Server Workloads to PostgreSQL: Quick Reference: Second Edition

Book: Migrate your SQL Server Workloads to PostgreSQL: Quick Reference – Second Edition

Shameel Ahmed
October 18, 2022October 22, 2022 1 Comment

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%
(Add your review)

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Contents

  • Serverless Basics
  • History of computing infrastructure and evolution of serverless
  • Cost Analysis
  • When to use serverless model
    • Variable Workloads
    • Event-driven Applications
    • Microservices
    • Rapid Development and Prototyping
    • Short-lived functions
  • When not to use serverless model
    • Steady or Predictable Workloads
    • Long running functions
    • Resource intensive tasks
    • Custom runtime environment or Non-standard Tech Stack
    • Stateful Functions
    • Large Data Transfers
  • The Amazon Prime case
  • A pragmatic approach to new development
  • Conclusion
  • References

Categories

.NET Architecture Artificial Intelligence ASP.NET AWS Azure Books C# Career Cloud CodeProject Conversational Bots Database Data Security Facade GCP IDEs Java Mobile MongoDB MySQL Open Source Patterns PostgreSQL Programming Python Redis Security Serverless SQL Server Tools Uncategorized Web Development Windows Phone

Recent Posts

  • Evaluating if Serverless is suitable for your needs – A comprehensive analysis September 17, 2023
  • 5 reasons you should switch from VS Code to VSCodium June 10, 2023
  • How to build a REST API using Amazon API Gateway to invoke OpenAI APIs March 11, 2023
  • How to fix “‘StreamingBody’ object is not subscriptable” in AWS Lambda boto3 February 12, 2023
  • How to invoke OpenAI APIs from AWS Lambda functions February 5, 2023

Archives

  • September 2023 (1)
  • June 2023 (1)
  • March 2023 (1)
  • February 2023 (2)
  • January 2023 (2)
  • December 2022 (1)
  • October 2022 (1)
  • July 2022 (2)
  • February 2022 (1)
  • November 2021 (1)
  • July 2021 (1)
  • June 2021 (1)
  • September 2020 (1)
  • May 2020 (2)
  • April 2020 (1)
  • October 2019 (1)
  • September 2019 (4)
  • July 2019 (2)
  • May 2018 (1)
  • September 2017 (1)
  • April 2017 (1)
  • April 2014 (1)
  • August 2011 (1)
  • June 2009 (1)
Copyright 2022. The Developer Space | Theme: OMag by LilyTurf Themes
  • DbStudio
  • Re:Link
  • shameel.net
  • Privacy Policy
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are as essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
SAVE & ACCEPT