Getting Started with AWS Lambda

Getting Started with AWS Lambda

AWS Lambda is a serverless computing service from AWS. Lambda enables you to run your code without provisioning or managing the servers.

Lambda runs your code on high-availability infrastructure and performs all operational or administrative tasks including provisioning the server, applying security patches to the underlying resources, operating system maintenance, monitoring, and logging the code.

You just need to supply the code in one of the languages that Lambda supports and it takes care of the rest. The code you upload and run on Lambda is called the Lambda function. With Lambda, we pay only for the time the code runs - there is no charge when the code is not running.

What is Serverless?

Serverless is a cloud computing execution model where the cloud service provider manages the servers and dynamically allocates the resources.

Serverless does not mean "no servers". Rather we don't need to think about the servers.

Need for serverless

Traditionally, you had to launch a server and set a runtime environment by installing the required language compiler. You deploy the application and must patch and update the server over time. All the management overhead like monitoring the application, and scaling the infrastructure as it handles more requests or in case of a resource crunch had to be looked after by the developer or an admin team.

With serverless, you can focus on the code, and the cloud provider abstracts away the management overhead.

However, there may be cases where traditional server architecture overshadows the serverless architecture.

Adv. and Disadv. of Lambda/Serverless


  • Focus on writing the code with no management overhead.

  • Pay-as-you-go pricing model. Pay only for the time the code runs.

  • Automatic scaling based on demand.


  • Limited control of the infrastructure like OS and libraries. No access to the underlying server.

  • It may experience latency as the runtime initialization takes time during the initial function invocations.

  • The code must be stateless. It shouldn't depend on or store information on the underlying server, or its file system.

  • Not suitable for long-running applications. The lambda function must complete its execution within 900 seconds (15 minutes). This is a limitation of the Lambda rather than a disadvantage.

When to use Lambda

Lambda is ideal for scenarios that must scale up rapidly, and scale down when not needed. Below are some use cases where Lambda can be used:

  • File processing

  • Stream processing

  • Batch processing

  • Data and Analytics

  • Cron jobs

  • Log analysis

How to invoke or execute Lambda functions

After you deploy your Lambda function, you can invoke it in several ways - Lambda console, AWS SDK, AWS CLI, etc. These are the direct ways of invoking a Lambda function.

However, since AWS Lambda is an event-driven serverless computing platform the most common use case is to invoke the function in response to events. For example, Amazon S3 can invoke a Lambda function when an object is uploaded to a bucket.

A function can be invoked either synchronously or asynchronously. Synchronous invocation is a mode where the requestor or calling service waits for the Lambda function to process the event and return a response. This mode is often used in real-time applications like data transformations or where the returned response is further connected for processing or user feedback.

In the case of asynchronous invocation, the requestor or calling service does not wait for the Lambda function to complete its execution and return the response. This means that the function output is not connected for further processing. It's like a worker process, it does its task and goes off. This mode is used for background tasks, batch processing, etc.

Lambda Runtimes

Lambda supports multiple languages through the use of its native runtimes. A runtime is a language-specific environment that passes the invocation events and responses between the Lambda service and a Lambda function.

Lambda supports the below programming languages natively:

  • C#

  • Go

  • Java

  • NodeJs

  • Powershell

  • Python

  • Ruby

You can also build a custom runtime.

Configuring Lambda functions

Apart from deploying our code to Lambda, we also need to set some configuration parameters on the function.

The basic configurations are

Memory: Amount of memory available to your Lambda function at runtime. Lambda automatically allocates CPU in proportion to the amount of memory configured.

Memory can range from 128 MB - 10,240 MB in 1-MB increments.

Timeout: It is the maximum amount of time that a Lambda function can run before timing out.

Timeout ranges from 3 seconds - 900 seconds (15 minutes)

Other configuration settings include networking, environment variables, ephemeral storage, and file system.


In conclusion, Lambda is a serverless, function-as-a-service (FaaS) cloud computing model where developers deploy and run their code without provisioning or managing the underlying infrastructure.

Happy Learning!