What is Serverless and how to go serverless?

Shaista Aman
4 min readFeb 3, 2022

--

Serverless does not mean to run code without servers but it’s basically running your code without provisioning / managing infrastructure. In serverless or Function as a Service (FaaS) model, you simply write code and upload it to lambda (AWS) or functions (Google or Azure Cloud). You have been given different runtime environments, configuration and performance to execute your code.

Part 1: Lambda Functions

Lambda is a transformative technology which will continue to gain adoption because it takes off the server maintenance and upgradation responsibility and lets you scale and concentrate on your business logic. As soon as a lambda function gets invoked it automatically responds to code execution requests at any scale, from number of events per day to hundreds of thousands per second.

Some of prominent features of Lambda are:

  • Saves cost by paying only for the compute time.
  • Optimizes code execution time & performance with right memory size.
  • Independent lambda functions reduce application complexity and development time when it scales.

Read More: https://aws.amazon.com/lambda/

Demo:

Create the function

In this demo we will create lambda function in console

On Lambda dashboard, open the Functions page.

Choose Create function.

Lambda Dashboard

Under Basic information, follow these steps:

Enter function name as myFunction.

Lambda create from scratch

For Runtime, select Node.js 14.x.

You can see that Lambda provides runtimes for different languages like .NET, Go, Java, Node.js, Python, and Ruby.

Choose Create function to complete the lambda creation process.

Also take into account that Lambda creates a Node.js function and an execution role that grants the function permission to execute your code and implement your business logic.

myFunction

Invoke the Lambda function

You can invoke your Lambda function by using sample event data already provided in Test of lambda.

To invoke a function select Test tab on your function.

Then choose New event. In Template area, leave the default hello-world and enter a Name for this test — testingLambda.

You can see following key-values in the sample event template:

{

“key1”: “value1”,

“key2”: “value2”,

“key3”: “value3”

}

Hit Save then choose Test. Every user can create up to 10 test events per function. Here lambda runs the function on your behalf when the function handler receives the sample event and processes it.

After execution you can view the results in the console.

The Execution result shows the success execution status. You can also see details by clicking expand Details and open the Log groups page in the CloudWatch.

The Summary section shows the key information reported and Log output section shows the logs that Lambda generates for each invocation. These logs are generated and can be seen in CloudWatch.

To create more metrics, run the function a few more times.

Now select the Monitor tab which displays graphs for the metrics that Lambda sends to CloudWatch.

Clean up

To delete a Lambda function, open the Functions page.

Select a function myFunction and select Actions, Delete.

On Delete function dialog box, hit Delete.

Delete the log group

Open the Log groups page of the CloudWatch and select the function’s log group (/aws/lambda/myFunction).

Select Actions, Delete log group(s).

In the Delete log group(s) dialog box, choose Delete.

To delete the execution role

Go to Roles page of the AWS Identity and Access Management (IAM) and select the function’s role (myFunction-role-xxxxxx).

Hit Delete role. In the Delete role dialog box, choose Yes, delete.

--

--

Shaista Aman

Shaista is a seasonal freelancer and technology evangelist. Founder EzzyApp & CEO 3C–Creators Cloud Club. She has keen desire of learning advance technologies.