What exactly is Serverless?

Azure Functions, Google Cloud Functions, AWS Lambda are some of the popular implementations of serverless computing available out there. But you might wonder what exactly is serverless, doesn’t it require a server? 
Yes, it runs on web servers and it does all that a web service (with a provisioned infrastructure of a web server) can do. But in this case, the code to run the web services is written by you and these cloud service providers do the rest of the work for you. That includes spinning up a virtual machine as the base infrastructure to run the web service, managing the operating system, installing the dependencies, running the code to evaluate the requests. This code needs to be in the form of independent functions or modules/classes. Let’s take NodeJs with Azure Functions for example, You need to write a nodejs module containing your logic, so that Azure knows what you want it to do.

A nodejs module as a “Function” in a “Azure Functions App”

If you have come across how micro-services architecture has brought reliability at scale to various tech giants such as NetFlix or Uber, you might be interested in knowing that all of the benefits of such architecture come hand in hand with adopting a serverless architecture.

Let’s try to understand how this works in a quickest way.

Configuring HTTP Triggers

Most common way to invoke a Function in AF is to attach a HTTP Trigger to it. Azure gives you an end point and you can configure what HTTP methods you want to support.

A Storage account in your azure (like Amazon S3) is created and used as a repository for your code and configuration files. Everytime a function is invoked by a trigger, Azure will deploy your code in a VM (the compute resource) and have it evaluate the request from the trigger with the function specified. once the outpur is available to the Functions Host, it is given back as the response to that trigger.

How a Azure Functions App Responds to HTTP Triggers.

There’s a bit more to the story,

Routing of a request to one of the compute resources.
  1. Everytime a function is invoked, Azure will look if that function is already in the runtime, only if it is not in the runtime, Function will be reloaded.
  2. Azure tries to keep the function in the runtime to avoid a slow responce due to loading time of a function, hence the function and the host VM is available for a few minutes after when the function was last invoked.
  3. With the increasing number of requests, Azure deploys same function on various machines to make it highly available. This means you need to write stateless functions because there might be more than one instances of your function at any given time.
  4. Billing: Azure only bills you for the actual execution time for your function. It has its own unit known as GB-Sec, so if your function is consuming 1 GB of memory for 1000 milliseconds in its execution, you will be billed 16 microdollors (Pricing is 0.000016 USD/Gb-Sec).

I hope you try Serverless for your next project.

Here are some more resources if you are looking to get deeper insights:

A Youtube playlist: introduction to azure functions

Here’s a bit advanced course on Serverless using Azure:


Like what you read? Give Omkar Dusane a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.