The Ops Community

Divyessh Maheshwari
Divyessh Maheshwari

Posted on • Originally published at Medium on

Serverless Architecture

Have you ever wondered how the AWS Lambda functions or Cloud Functions by Google or other Functions as a Service work? or is serverless architecture really serverless? or how a third-party service manages your complete backend service code in containers?

In this post, we are going to understand the serverless architecture and how it actually works. We are also going to explore the answer to the question, is serverless architecture really serverless? and we are also going to explore how this architecture is provided in handy to us by different cloud providers like AWS, GCP, and many others. We will also take a look at what is FaaS (Function as a Service) and how we can actually implement a FaaS using any of these cloud providers.

To have a better understanding of this article, I really recommend you to read one of my previous articles on “Basics of Web App Architecture” and if you want to know more about the cloud, check out “Cloud Computing”. In case you already have an understanding of how the web works and what are some different commonly used web architectures, feel free to move ahead.

Introduction

Serverless architecture is one of the modern forms of web architecture where we deploy our application that incorporates the third-party services that manage the server configurations, load balancing, and other server-side tasks.

The distribution of the services that need to be provided in the backend is somewhat similar to the microservice architecture. Just like in microservice architecture, the backend is distributed among different services, each of them being used for different tasks, in serverless architecture (especially in FaaS), the backend is divided into different tasks, and each of these tasks can be implemented as a separate and individual function. These functions are then served through an API over different endpoints and can be accessed by the frontend.

This is what a basic application built over serverless architecture would look like.

Function as a Service (FaaS)

FaaS is the most popular and newer implementation of serverless architecture. In this implementation, we create multiple functions to perform each task which is an independent part of the backend server logic or service.

Let us consider the case of AWS Lambda functions to understand this.

“AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers.” ~ https://aws.amazon.com/lambda/

The lambda functions do not require you to manage their deployment or load balancing yourself, and rather the infrastructure of AWS manages that for you. These functions are deployed as containers on the server, where each server can have multiple function instances running on it depending upon the user traffic and computation power required by the functions.

These are very easy to build and AWS allows you to integrate many other services like DynamoDB ( AWS NoSQL Database ), S3 (Storage Service), SQS (Queuing System), SNS (Notification System), and so on.

Lambda functions are not only easy to build and deploy but they are also very cost effective since you are charged on the basis of computation time used by the function instances, which is only accounted for when the function is called. AWS even provides you with about 1 million free requests and 3.2 million seconds of compute time per month.

Use Cases and Limitations

Now let us have a look at some different cases where we can actually use the serverless functions and how it will be beneficial for us, or what can be some of the limitations.

Data Processing or Collection

Lambda functions can be great for the lightweight processing of data for an application since they generally do not take much compute time and it will be very easy to store the data using other services. You can create a very small function to just store the form data of a web application submitted by a user to DynamoDB (Database), and later use that data for self-analysis.

Backend Logic (CLient Heavy Application)

Since for the client-heavy applications, the backend is very lightweight and has high latency, the backend or server side logic is very easy to be implemented in the lambda functions and since you do not have to manage your deployment, it becomes somewhat similar to Backend as a Service (BaaS), which basically are platforms that provide you with backend without you requiring to manage it.

You will not need to know concepts like the CI/CD pipelines or other DevOps-related concepts to scale or deploy your logic.

The client heavy applications might include a personal blog, a designing application, or any other application where a good part of logic is implemented over frontend.

Limitations

When a lambda function is left idle for some time, they are required to go through a cold start which means it takes time to start and respond. So if a quick response is needed, and there can be an expected low traffic period, then lambda functions are not very suitable. Also when the applications have a heavy backend, which would require a lot of computation power, then we should ideally not use lambda functions, since they are not efficient in those use cases.

For example, you should not use Lambda functions for MLOps ( Deployment of ML Models ), since they can require very high computation and have high latency.

Conclusion

Serverless architecture is a great framework to be implemented in your applications. With its many advantages, it also has some limitations, and hence as a best practice, you should not depend solely on lambda functions for your backend, and instead develop a hybrid backend, with the lightweight functions getting implemented by the serverless functions. This will not only reduce loads of you for management of the server logic but also let you focus more on the main product or service that you intend to provide.

Now that you understand the basic function of serverless architectures, we can move on to understanding more details of cloud computing and architecture. We can explore other forms of architecture as well as understand how each of these cloud functionality works individually.

To support my articles, you can check out my official blog at Thinkfeed and subscribe to the newsletter over there so that you never miss a post and keep yourself updated. Enjoy Reading!

This article was originally published on https://thinkfeed.divyesshm.com/post/serverless-architecture

Discussion (0)