The term ‘Serverless’ is a bit of false advertising and this word became more of a buzzword. As always Buzzwords tend to lose their meaning, it’s more about the power of the word than what that word means.
So what does Serverless mean or represent?
Serverless does not mean there will be no server to run your code. That just means you do not need to worry about running and maintaining these servers. The cloud providers like Azure, AWS & Google still have hundreds of thousands of servers.
How does everything work??
Serverless computing means building applications without thinking about servers. Now that does not mean thinking about server boxes, as software developers you normally do not think about server boxes anyways. What it means with serverless you do not have to think about things that you normally think when you have a server box available.
- Server configurations
- Setting up runtime libraries such as .net framework, node etc
- Processing power
These are the things you care about when you are working with the actual server. Serverless architecture abstracts that away and all you have to think about is YOUR CODE !!!
Let’s understand this by an example
Azure functions in Azure or lambda expressions in AWS are examples of serverless computing also known as Functions as a Service.
Using Azure functions you create a simple function. This could be as simple as a single code file with a single method written in it. Now you can call this method in several ways. We call these triggers. These triggers could be a URL, a timer like a scheduled job or even some event that happens in other Azure services.
Following is a simple example of an azure function
Azure function projects are just folders. Inside each folder, we have a function file. This shows us that to make Azure function work, all you need is a single with a single method. You tell the Azure function that this function should be invoked with an HTTP request and the Azure function turns into an endpoint and gives you a URL to call.
You do not have to worry about configuring the web framework, routing, request handling, scaling etc. All you think about is your code & business logic. This is the essence of serverless.
Benefits of using serverless
Cheap: No server means nothing to pay for? Only pay for what you use.
Easy: Much less time to set up and deploy. Put your code in the cloud and it just works.
Practical: Good for all sorts of applications from microservices to APIs to one-off business needs.