Serverless architecture or serverless is the only thing everyone’s raving about in the software architecture world. The three main cloud vendors- Google, Microsoft, and Amazon- are heavily involved in the process of serverless, and this has intrigued the whole world about the benefits of going serverless. However, before anything else, one must thoroughly explore what it means to be ‘serverless’.
Serverless architecture means providing backend services to the user on an as-used basis. With a serverless provider, a user can use all their energy on writing and deploying the code instead of having to worry about the underlying infrastructure. Being serverless does not mean that there’s no server in existence, although the name suggests otherwise there is a server present, however, the user does not need to know or care about its existence at all. The Serverless provider services auto-scaling thus the company that’s using the service is charged based on consumption by the user and does not have to reserve and pay as per the number of servers or for a fixed amount of bandwidth.
In this article, we’re going to study serverless architecture in detail while covering topics such as-
- Traditional Method vs Cloud Computing vs Serverless Architecture
- Origin of Serverless- New vs Old
- Serverless Stack
- Use cases for serverless architecture
1. Traditional Method vs Cloud Computing vs Serverless Architecture
In the early days of the web, it was required that one owns the physical hardware required to run a server if one wanted to build a web application. Doing this was quite expensive and required a lot of storage space. After this came cloud computing which allowed businesses to rent a fixed number of servers or server space remotely. However, more often than not companies ended up purchasing extra space or some other factor that made them unable to use the rented space which resulted in a lot of money going to waste. To rectify this issue cloud vendors came up with solutions such as auto-scaling but were unable to deal with unwanted spikes in activities such as DDOS attacks, etc. Thus, even with auto-scaling, cloud-computing solutions end up being quite expensive for business users. After this came Serverless computing which allows paying for the cloud-based computation time as needed and one does not have to rent a fixed number of servers.
2. Origin of Serverless- New vs Old
When it comes to the term serverless there are a lot of misconceptions in the industry. There are multiple meanings of the term floating around that more or less end up confusing everyone. Serverless was first used as a term in 2012 in an article by Ken Fromm. Ken uses the term in the context where someone outsources the management of server-side logic and states to a third-party cloud-based service or application. This method is more commonly known as BaaS or backend as a service.
The term serverless has evolved to mean entirely something else. It became popular around 2015, following the AWS Lambda launch in 2014, and became even more popular in 2016 after the launch of Amazon’s API Gateway. The new and evolved meaning of serverless architecture refers to applications where application developers have to care only about writing the server-side logic, and can leave the rest to a third party. Unlike the traditional architecture, these logics are run in stateless compute ephemeral containers (lasts for one invocation), event-triggered, and completely handled by third-party vendors.
3. Serverless Stack
To understand serverless architecture even better, we’re going to define it as a set of common attributes, instead of focusing on it as an explicit technology. Doing this allows us to understand how the serverless method can reflect in other main areas of the stack-
- FaaS or function as a service
FaaS or Function as a Service is the central processing engine in most serverless architectures. People often confuse FaaS and serverless architecture as the same, but in reality, FaaS is a subset of serverless. Fundamentally, FaaS means running backend code without having to worry about long-lived server applications or managing your server applications. It makes it easier for cloud application developers to manage and run microservices applications.
Typically, hosting a software application on the web requires managing a virtual or physical server. However, with FaaS your cloud service provider handles the physical hardware, web server software management, and the virtual machine operating system.
- Serverless databases and storage
Object storage and databases such as SQL and NoSQL are the foundation of the data layer. To achieve a smooth transition the storage and database need to move towards models that scale linearly in respect to both pricing & infrastructure and move away from being limited in capacity, query limit, and connection.
- Event streaming and messaging
Serverless architectures are ideal for event-driven and stream-processing workloads, such as the Apache Kafka event streaming platform, which is open-source.
- API Gateways
An API gateway is an HTTP server containing configuration files that define routes and endpoints, as well as resources that handle those routes. Additionally, it works as a proxy to web actions and provides client ID and secrets, CORS, rate limits, viewing response logs, viewing API usage, and API sharing policies.
4. Use Cases for Serverless architecture
Serverless architecture is suitable for performing short-term operations and managing workloads with intermittent or unpredictable traffic patterns. Some of the main use cases for serverless are-
- Trigger-based Tasks – An action or series of actions triggered by any user activity is a good candidate for serverless architecture. For instance, if a new user is signing up on your website it may trigger the database change and this going forward will trigger a welcome mail. Such backend tasks can be easily handled by a chain of serverless functions.
- Building RESTful APIs- You may create RESTful APIs that scale with demand using Amazon API Gateway and serverless functions.
- Many of the stages in your Continuous Integration(CI) and Continuous Delivery(CD) can be automated using serverless architecture.
- Asynchronous Processing- Serverless functions are asynchronous which allows them to handle back-end application tasks such as transcoding videos after upload or rendering product information, without adding any user latency or in any way interrupting the flow of the application.
- Security Checks- Serverless functions can be used as a more secure option for two-factor authentication and SSH verification. For example, when a new container is spun up, its vulnerability or misconfigurations can be scanned by invoking a function.
Although serverless helps deal with a lot of issues it is not the solution to every problem and be wary of people that tell you that serverless will replace all of your existing architectures. While there are numerous benefits to serverless architecture like scaling and less deployment effort, there are some limitations as well.
Read here| Benefits and Limitations of Serverless Architecture