Back in the day, we only had physical hardware to run the application, and it will take months to get new computational units. Scaling took a lot of operational overhead and we are limited to the physical capacity. After the invention of virtual machines, the time to provision new compute units is reduced to minutes, which leads to the era of cloud computing. Cloud computing transformed the face of the IT industry. Cloud computing lets us provision cheaper, quicker, controllable, and much smoother resources online than the expensive physical resources. Today, containers let us create a new compute unit in seconds. Containerisation breaks our large monolithic application into small, decoupled, independent micro-services that connect back together to run our application. The next major transformation in cloud computing is usually known as “Serverless”.
Serverless goes one step further and breaks the micro-services into multiple functions and that’s why it is also termed as Function as a Service (FaaS). In serverless architecture, you, only pay for the resources consumed by your application and this saves a lot of money and operational overhead. Scaling and deploying made easier and also gives you the ability to scale the individual functions in your application
“Serverless” doesn’t mean servers are not involved, they still exist under the application. It simply means that we don’t need to think about provisioning or managing the servers.
One of the main problems we face while hosting our servers in traditional cloud hosting is, we will either end up over-provisioning or under-provisioning our servers. Because it is very difficult to forecast or guess how much traffic we will receive all the time. Over-provisioning servers will cause us huge additional costs for that unused idle capacity of servers. If you under-provision the servers to cut the cost, during high traffic your site will crash, this will affect your reputation and you will lose your viewers.
Operational Management in traditional server hosting is high and difficult. You have to regularly update your server OS, patching, and configurations.
You need to architect your infrastructure in the cloud.
You may face a lot of confusions and questions like,
What type of virtual machine I should use?
What OS I should use?
How much memory do I need?
How much CPU do I need?
How many virtual machines do I need?
How should I scale my application?
Serverless provides answers to all these questions and the answer is simple “you don’t need to worry about these questions”.
Serverless computing is responsible for executing a code by dynamically allocating the required resources. And the only charge for the resources used. Serverless provides the following benefits,
No server management
There is no need to manage or configure servers and their maintenance.
The serverless services scale up or down based on the load. A serverless application can handle an unusually high number of requests and scale automatically based on the load.
Run closer to the user
Since the code is not deployed on the virtual machine. Based on the cloud provider it is possible to run the code in different regions in the world which is nearer to the end – user.
Pay as you go
You pay only for the resources you use to run the code. You don’t need to pay for an entire virtual machine. If the resource is not utilized, you won’t be billed.
In serverless architecture, you can create as many environments as you need which gives you the ability to create demo environments for a new feature.
Disadvantages of serverless architecture
- Vendor lock-in: Allowing a vendor to provide all the backend services for an application surely increases dependence on that vendor.
- Architectural Complexity: There is a lot of learning and R&D is involved in serverless. You’ll have to deal with containers, micro-services, and functions.
- Difficult to Debug: It is difficult to reproduce the serverless environment to debug how the code is executed.
- Cold start: Typically when a particular serverless function like lambda has not been invoked in a while, the vendor shuts down the function. The next time a user runs an application that calls that function, the vendor will have to startup the function freshly. This startup time leads to significant latency.
Example: Serverless thumbnail generation
The above example is a serverless thumbnail generator, when an image or video is uploaded to the S3 bucket, it triggers the serverless Lambda function which creates the thumbnail and stores it in an s3 bucket, and saves the thumbnail location in a Dynamo DB. The insert into the Dynamo DB could then trigger further lambda functions. This function runs only when it is triggered and scales automatically based on the load
Major cloud providers like AWS, GCP, Azure are pushing heavily to make their platforms more Serverless – oriented and a lot of updates are coming every day. Serverless will continue to develop quickly and, if you’re continuing to extend your cloud computing skills, acquiring how to tackle Serverless is recommended.