Cloud computing has recently gone through a huge shift in the paradigm of software development in modern software engineering. No longer do developers wish to spend their precious time configuring and managing virtual machines and their operating system updates, as well as dealing with the often complex process of auto-scaling security groups. Serverless Computing, the new execution model of cloud-based applications, is revolutionizing how software is developed, deployed and scaled in order to best serve users of modern applications.
This training is designed for computer science students, developers and other career enthusiasts who want to get up to speed on serverless computing quickly. Whether you are just starting out and are looking to get into cloud architecture or simply want to future-proof your skills, this training on Serverless Computing: Architecture, Benefits & Use Cases will give you the knowledge you need to stay ahead of the curve.
What is Serverless Computing? (Understanding the Core Concept)
Contrary to the name of “Serverless Computing," servers are not excluded from the whole computing environment. Rather, as opposed to managing, provisioning and monitoring servers that developers have to do in traditional cloud computing environments (IaaS, PaaS provided by Amazon Web Services, Microsoft Azure, Google Cloud Platform, etc.), all the cloud computing infrastructure is abstracted away from the developers by serverless computing providers.
On the other hand, traditional cloud applications (IaaS or PaaS) are usually provisioned as virtual servers, which are rented per hour. Regardless of whether the servers are busy or not, servers need to be kept up-and-running all the time so that future requests can be serviced. In addition to the cost of maintaining idle servers, there is also the challenge of auto-scaling of resources. All of this can result in substantial waste and prevent developers from focusing on delivering value. Serverless applications, on the other hand, are provisioned as event-driven functions that execute only when specific events occur (e.g. API method calls, database row updates, image uploads, etc.). These functions execute in a matter of milliseconds and automatically scale up from zero to thousands of instances to handle peak loads. And, as with all serverless applications, developers only pay for the exact amount of time their code ran and the amount of memory that was consumed.
┌─────────────────────────────────────────────────────────────────────────────┐
│ SERVERLESS EVENT-BASED WORKFLOW PROCESS │
├───────────────┐ ┌─────────────────────────┐ ┌─────────────────────┤
│ Event Source │ ---> │ Serverless FaaS Engine │ ---> │ Managed Services / │
│ (HTTP/S3/DB) │ │ (AWS Lambda / Azure) │ │ Database (DynamoDB) │
└───────────────┘ └─────────────────────────┘ └─────────────────────┘
Key Components of Serverless Computing Architecture
Understanding the key components of the serverless computing architecture is vital for anyone who wants to be a master of serverless computing architecture. In order to design a serverless architecture, first, it is imperative that we have to decompose the monolithic codebase into different modules.
┌──────────────────────────────┐
│ API Gateway (HTTP Routes) │
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ FaaS (AWS Lambda Exec) │
└──────────────┬───────────────┘
│
┌────────────────────┴────────────────────┐
▼ ▼
┌──────────────────────────────┐ ┌──────────────────────────────┐
│ BaaS (DynamoDB / Auth) │ │ Event Stream / Storage S3 │
└──────────────────────────────┘ └──────────────────────────────┘
1. Function-as-a-Service (FaaS)
This is the core of serverless computing. FaaS is a fully-managed compute service that allows you to upload and run your own functions as needed. More and more applications are supported by well-known cloud providers such as AWS Lambda, Azure Functions and Google Cloud Functions. All functions work in an entirely separate environment referred to as the stateless container.
2. Backend-as-a-Service (BaaS)
Backend-as-a-Service (BaaS) - These are third-party cloud services used to create applications with features of the serverless backend without having to construct an entire server infrastructure. It could be managed NoSQL databases (such as AWS DynamoDB or Google Cloud Firestore), Authentication Services (like Auth0 or AWS Cognito) and cloud storage (like Amazon S3).
3. Event Triggers and Event Buses
In Serverless computing architecture the execution of functions and services is initiated by an event, which could be for example a user uploading a document into the storage bucket, an HTTP request or API call to API Gateway, database row updates, or even a scheduled cron job. These event triggers are handled using an event router such as AWS EventBridge or Azure Event Grid, among others.
4. API Gateway
API Gateway serves as a front end of your serverless backend application and handles HTTP and WebSocket events from web browsers and mobile applications.
Real-World Use Cases of Serverless Architecture
While learning the many theoretical cases for serverless computing is very interesting, there is nothing that brings home the power of serverless computing for real-world industry use cases as examples of these!
┌─────────────────────────────────────────────────┐
│ SERVERLESS REAL-TIME USE CASE │
└────────────────────────┬────────────────────────┘
│
┌─────────────────────────────┼─────────────────────────────┐
▼ ▼ ▼
┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ 1. RESTful API Endpoints │ │ 2. Real-Time Image │ │ 3. Automated Data │
│ & Microservices │ │ Processing │ │ ETL Pipelines │
└─────────────────────┘ └─────────────────────┘ └─────────────────────┘
1. Building Scalable Web & Mobile APIs
APIs for modern web applications (so called RESTful APIs as well as GraphQL APIs) can be easily implemented using Amazon API Gateway and AWS Lambda functions. Each API endpoint can then be mapped to a corresponding serverless function. Such a function can then in turn compute everything (e.g. reading input from users, interaction with databases, computing results and returning them in JSON format) from within the function itself.
2. Real-Time Image and File Processing
You could also use serverless computing functions to automatically resize a user’s uploaded profile pictures for other uses within your social media application, like creating thumbnails for example. These uploaded images are saved in an Amazon S3 bucket and as soon as the uploading process is done, an event occurs triggering a serverless function that resizes the image and recompresses the image along with updating the corresponding database entries.
3. Automated Data Processing and ETL Pipelines
Serverless computing functions can consume real-time log files, process the incoming telemetry data streams, carry out analytics processing and then move the cleansed data to data warehouse services like BigQuery or Snowflake. Banking organizations, E-commerce websites and IoT networks produce vast amounts of Streaming Data on a daily basis.
4. Scheduled Background Jobs and Cron Tasks
The background jobs required by every organization (e.g. sending out weekly subscription emails, performing a database clean-up on a regular basis, etc.) can all be handled by serverless functions running as scheduled cron jobs that run once a week/once a month/once a day, etc. and are up and running in an instant to complete their task, only to shut down instantly as well.
Serverless vs. Traditional Cloud Models (IaaS, PaaS, Containers)
In this section we explore Serverless computing in contrast to more established cloud models such as IaaS, PaaS and CaaS-based computing.
┌────────────────────────────────────────────────────────┐
│ CLOUD COMPUTE SPECIFICITY LEVELS │
├────────────────────────────────────────────────────────┤
│ [IaaS] Virtual Machines (AWS EC2, Compute Engine) │
│ [PaaS] Managed Platforms (Heroku, AWS Elastic Bns) │
│ [CaaS] Containers & Orchestration (Docker, K8s) │
│ [FaaS] Serverless Functions (AWS Lambda, Cloud Run) │
└────────────────────────────────────────────────────────┘
- IaaS—Virtual servers offered as managed services (example: EC2). In this case, the user bears the responsibility of managing his/her virtual machine, whereby he/she will be required to update the OS and install other applications.
- PaaS—Platform as a Service (higher level of abstraction, but the user manages the instance of the application).
- Container (Docker and Kubernetes)—Perfect choice for portable applications.
- apps. Custom runtimes can be created for performing background processes. But to manage a Kubernetes cluster, for instance, one needs special DevOps expertise.
- Serverless (FaaS): Execution, patching, scalability, and fault tolerance are all offered by the cloud provider.
- Serverless (FaaS): Execution, patching, scaling, and fault tolerance are all offered by the cloud provider.
Tradeoffs of Serverless Architecture
There are other aspects and tradeoffs related to serverless architecture, which the cloud engineer designing the architecture needs to consider.
Managing Cold Starts
A cold start is the very first invocation of a serverless function after it has been idle for a while. Initializing the container runtime and loading the code for the function can take some time and add initial latency to the function’s execution. The Cold Start can range from 100 ms to 500 ms, and at times even longer than this. In order to avoid Cold Start times, keep the size of packages small and use efficient runtime engines like Node.js. or Go. Another way to prevent cold starts is to use provisioned concurrency.
Addressing Vendor Lock-in
Vendor lock-in may occur when there are heavy custom integrations with vendor-specific proprietary cloud platforms like AWS Step Functions and Azure Logic Apps. Use of open source frameworks to deploy serverless applications such as Serverless Framework or Terraform is recommended to avoid vendor lock-in. Business-logic code needs to be kept decoupled from the SDK of the providers.
Observability and Distributed Tracing
Serverless applications are made up of many distributed, stateless functions that asynchronously communicate with each other. Because of this, typical logging tools are not sufficient to identify latency or debug errors in serverless applications. Dedicated distributed tracing tools such as AWS X-Ray, Datadog or OpenTelemetry need to be employed for this task.
Frequently Asked Questions (FAQs)
1 Is serverless computing truly free of servers?
No, there are still servers. The expression serverless computing simply means that all management, provisioning, security updates etc. of servers is taken care of by the cloud provider, so that you as a developer do not have to deal with the underlying hardware.
2 What is a cold start in serverless functions?
The first call to a serverless function can incur a delay as the cloud provider has to spin up a container instance and load in all the dependencies for execution. This delay is commonly known as a ‘cold start’ and can be on the order of milliseconds.
3 How does billing work in serverless computing compared to traditional hosting?
As opposed to traditional cloud hosting where you pay for a fixed amount of time for virtual servers that are always up and running (regardless of usage), serverless computing is charged by the amount of time a function executes (down to the millisecond) and by the amount of memory a function uses while running.
4 Which programming languages are supported in serverless platforms?
Serverless Platforms support all major programming languages like Node.js (JavaScript/TypeScript), Python, Go, Java, C# (.NET) and much more. In fact, most of the platforms allow custom Docker container runtimes, so that you can run any programming language of your choice within your function.
5 When should I avoid using serverless architecture?
Serverless architecture does not work well with huge predictable amounts of activity (for example batch processing, scheduled jobs, etc.), long running jobs (that are going to take more than 15 minutes of runtime available in Lambda), or with legacy monolithic architectures (also known as simple Single Page Applications orolithically simple applications).
Related Links:
Resume Tips For Software Developers
Do visit our channel to know more: SevenMentor
SevenMentor
Expert trainer and consultant at SevenMentor with years of industry experience. Passionate about sharing knowledge and empowering the next generation of tech leaders.