What is AWS Lambda?

By Blue Matador on June 11, 2020

What is AWS Lambda?

Lambda is an AWS service that allows you to run your code completely in the cloud without the need for on-prem servers. As the world has shifted away from on-prem and toward serverless computing, Lambda has grown in popularity: 1700 companies report using Lambda as part of their data infrastructure in StackShare.

Top 7 Lambda metrics to monitor >

How does AWS Lambda work?

In a nutshell, Lambda allows you to portion out pieces of your own code and trigger those pieces to run when certain events, determined by you, occur. 

How Lambda works

Writing code

You can write your code in your own code editor and upload it to Lambda, or you can write directly in the Lambda UI itself. 


Once you’ve written code, you need to customize your configuration with the amount of memory and max execution time for each function and when to run it. You can also integrate your function with various AWS services like S3, DynamoDB, Kinesis, SNS, etc. 

Event triggers

You can set a trigger to run your packaged code based on certain events. When your event occurs, your function runs and executes your code, then shuts off to wait for the next time it triggers.

Check out AWS docs for sample events.


Because your code is running only some of the time (just when it’s triggered), Lambda can be economical. You’re not charged for when it’s not running. Lambda pricing is based on number of requests (20 cents per 1M requests) and their duration (.00166667 cents for every GB-second). There’s also a free tier of Lambda for up to 1M free requests per month and 400,000 GB-seconds of compute time per month.

What can AWS Lambda be used for?

Lambda is highly flexible and can be used for a number of different use cases. There are basically two types of Lambda invocations: synchronous and asynchronous.

With synchronous invocations, services depend on the response from your function. If there are errors, they will propagate to the caller.

For example: If someone makes an API request on your website and you’re using API Gateway, API Gateway can pass that request on to Lambda, which then performs the function and passes it back to API Gateway, which then presents the user with the result.

For asynchronous invocations, Lambda puts the event in a queue to pass to your function. The other service registers the item queued and gets a success response immediately. In case of error, Lambda will try again. Asynchronous invocations are probably the most common use case for Lambda, so we’ve included a couple of examples this time.

Example 1: Say you run an email newsletter and have a database of subscribers in DynamoDB. This database is accessed by several systems determining who is interested in which topics, what the spread of time zones are among your subscribers, etc.

When someone unsubscribes, data about the user that unsubscribes is sent to Lambda, and the function written to handle that data is triggered. As the function executes, it can trigger other functions that do cleanup work, as well as delete any associated data from S3, RDS, and anywhere else it might live.

Example 2: If you’re running a real-estate app, people probably want to see a lot of photos displaying the outside and inside of every home listed. You might want to determine default image sizes for different sections of your app or resize certain images for thumbnails. 

You can trigger a Lambda function that will automatically take an uploaded photo and adjust it to the sizes you need and store them asynchronously.

Sample of image processing with Lambda

What does AWS Lambda play nicely with?

Languages compatible with Lambda

Out of the box, Lambda supports:

  1. Node.js
  2. C#
  3. Java
  4. Python
  5. PowerShell
  6. Go
  7. Ruby

However, Lambda also provides a runtime API to allow you to use additional programming languages.


Other AWS services that work with Lambda

Lambda can read events from Kinesis, DynamoDB, and SQS.

ELB/ALB, API Gateway, Cloudfront, and more invokes functions synchronously with Lambda. 

Services that use asynchronous invocations include:

  • DynamoDB
  • S3
  • SNS
  • SES
  • CloudWatch logs and events

For a full list, check out the AWS Lambda docs.


Lambda is a convenient, cost-effective way to run your code in the cloud instead of on-prem servers. It's highly flexible and is useful in a number of situations. 

What to Read Next

Subscribe to get blog updates in your inbox.

Discover critical system issues
Start your free trial today