r/awslambda • • Apr 06 '21

Tackling Java cold startup times on AWS Lambda with GraalVM

Thumbnail
arnoldgalovics.com
5 Upvotes

r/awslambda • • Feb 17 '21

Serverless TypeScript: A complete setup for AWS SAM Lambdas

Thumbnail
evilmartians.com
5 Upvotes

r/awslambda • • Dec 01 '20

New for AWS Lambda – Functions with Up to 10 GB of Memory and 6 vCPUs | Amazon Web Services

Thumbnail
aws.amazon.com
5 Upvotes

r/awslambda • • Jul 12 '19

Show Reddit: Lambda checklist

5 Upvotes

(cross-posted from r/serverless)

I made up this checklist to eliminate much of the guesswork while working with AWS Lambda. You can have it open every time you're editing templates and tick items as you go.

It includes:

  • useful IDE plugins to install

  • security scanning tools

  • what best practices to follow

and a few other stuff.

You can expand the items to reveal links to docs and tools

I did a similar checklist for CloudFormation and it was well-received in the r/aws.

https://www.reddit.com/r/aws/comments/ca59oy/show_reddit_cloudformation_checklist/

Here it goes:

https://lambdachecklist.com

Let me know what you think!


r/awslambda • • Jun 12 '19

AWS Lambda Timeout Best Practices

Thumbnail
lumigo.io
5 Upvotes

r/awslambda • • May 22 '19

Hilarious blog compares GOT characters and AWS services

5 Upvotes

r/awslambda • • Dec 03 '18

Asynchronous Micro Services with Serverless and AWS Step Functions

Thumbnail
medium.com
5 Upvotes

r/awslambda • • Mar 07 '17

How to use AWS Step Functions with Serverless Frameworks and Lambda

Thumbnail
youtu.be
5 Upvotes

r/awslambda • • Aug 28 '26

AWS Lambda introduces managed runtimes in public preview for Node.js 26 and Python 3.15

Thumbnail aws.amazon.com
4 Upvotes

Python 3.15 coming soon!


r/awslambda • • Jan 27 '26

Per-customer AWS accounts vs shared account (Multi-tenant AWS serverless SaaS)

4 Upvotes

Hi,

I'm building a solution to make it easier to create workflows and deploy it to AWS as a collection of lambda functions / SQS / Dynamo and S3.

From what I know, the best solution for that is to create a new account for each user and deploy it there, having an environment completly separated.

But, what if I need too many accounts? For example, free users that likely come and go. Should I create a shared account for free users? Even though it won't have the max security?

Other doubt: I plan to get logs from AWS CloudWatch to block accounts that are abusing the free account in some sense. Is there a better way to do it? Or is this a good to go?

Thx a lot for the help!


r/awslambda • • Mar 20 '24

AWS Lambda Under the Hood

4 Upvotes

View and Save the summary here
Summary was created with Recall
Original Source here

Lambda Architecture

  • Lambda is a serverless computer system that allows users to execute code on demand without managing servers.

  • Lambda supports synchronous and asynchronous invocation models.

  • Lambda's tenets include availability, efficiency, scale, security, and performance.

Invocation and Execution

  • Invoke request routing connects microservices and provides availability, scale, and execution access.

  • Worker manager reuses previously created sandboxes to reduce initialization latency.

  • Assignment service replaced worker manager to provide reliable distributed and durable storage for sandbox states.

  • The introduction of a new node allows for easy rebuilding of the state from the log, significantly increasing system availability and making it fully tolerant to single host failures and availability zone events.

  • The distributed consistent sandbox state is implemented regionally, and a leader-follower architecture is applied for quick failovers.

Compute Fabric

  • Compute fabric owns all the infrastructure required to run code, including worker fleets, capacity manager, placement, and data science team for smart decision-making.

  • Rust was used to rewrite the new service, increasing efficiency and performance of every host, improving processing volume, and reducing overhead latency.

Isolation and Security

  • Data isolation is crucial to prevent interference between different functions running on the same worker.

  • Virtual machine isolation provides sufficient guarantees to run arbitrary code in a multi-tenant computer system.

  • Firecracker is a fast virtualization technology specifically designed for serverless compute needs, allowing multiplexing of thousands of functions from different customers on the same worker with consistent performance.

  • Firecracker provides strong isolation boundaries, is very fast with little system overhead, and enables decorrelation of demand to resources for better control of worker fleet heat.

  • A custom indirection layer enforces strict copy-on-read to eliminate shared memory and prevent security threats in a multi-tenant execution environment.

  • Introduced a callback interface to restore uniqueness of code after resuming multiple VMs from the same snapshot.

Performance Optimization

  • Snapshotting is used to reduce the cost of creating new execution environments by resuming VMs from snapshots instead of initializing them from scratch.

  • Implemented on-demand chunk loading to reduce snapshot distribution time and improve performance.

  • Utilized convergent encryption to deduplicate common chunks across container images and increase cache locality.

  • Addressed the issue of inefficient memory access by recording page access patterns and optimizing snapshot loading.

  • Enabled Lambda snapshot on Java functions for users to experience VM snapshot functionality.

Additional Information

  • Firecracker uses a distributed cache in multiple availability zones to maintain a coherent cache of the configuration database, making lookups faster.

  • The speaker is open to discussing how Lambda functions can be built in a company's own data center during a follow-up talk.

  • The same techniques used in Firecracker could be used to make EBS snapshots faster, but it would require more work due to the complexity of hardware and virtualization layers.

  • Different services communicate with each other using a mixture of synchronous request-response communication and GPC and HTTP2 streams, depending on the requirements of the particular communication.

  • Firecracker uses metal instances because they meet the requirements of the system, while nested virtualization would be much slower.

  • During Lambda function updates, the previous function version is used until the snapshot of the updated function is finished, at which point the system switches to the latest version.

  • The engineering process balances security, efficiency, and latency, with security being the top priority.


r/awslambda • • Jan 31 '24

How do I add Python packages with compiled binaries to my deployment package and make the package compatible with Lambda?

4 Upvotes

I've been trying to deploy a Python AWS Lambda function that depends on the cryptography
package, and I'm using a Lambda layer to include this dependency. Despite following recommended practices for creating a Lambda layer in an ARM64 architecture environment, I'm encountering an issue with a missing shared object file for the cryptography package.

Environment:

  • Docker Base Image: amazonlinux:2023

  • Python Version: 3.9

  • Target Architecture: ARM64 (aarch64)

  • AWS Lambda Runtime: Python 3.9

  • Package: cryptography

Steps Taken:

  1. Pulled and ran the Amazon Linux 2023 Docker container.

  2. Installed Python 3.9 and pip, and updated pip to the latest version.

  3. Created the directory structure /home/packages/python/lib/python3.9/site-packages
    in the container to mimic the AWS Lambda Python environment.

  4. Installed the cryptography package (among others) using pip with the --platform manylinux2014_aarch64 flag to ensure compatibility with the Lambda execution environment.

  5. Created a zip file my_lambda_layer.zip from the /home/packages directory.

  6. Uploaded the zip file as a Lambda layer and attached it to the Lambda function, ensuring that the architecture was set to ARM64.

When invoking the Lambda function, I receive the following error:

{ "errorMessage": "Unable to import module 'lambda_function': /opt/python/lib/python3.9/site-packages/cryptography/hazmat/bindings/_rust.abi3.so: cannot open shared object file: No such file or directory", "errorType": "Runtime.ImportModuleError", "requestId": "07fc4b23-21c2-44e8-a6cd-7b918b84b9f9", "stackTrace": [] }  

This error suggests that the _rust.abi3.so file from the cryptography package is either missing or not found by the Lambda runtime.

Questions:

  1. Are there additional steps required to ensure that the shared object files from the cryptography package are correctly included and referenced in the Lambda layer?

  2. Is the manylinux2014_aarch64 platform tag sufficient to guarantee compatibility with AWS Lambda's ARM64 environment, or should another approach be taken for packages with native bindings like cryptography?

  3. Could this issue be related to the way the zip file is created or structured, and if so, what modifications are necessary?

Any insights or suggestions to resolve this issue would be greatly appreciated!


r/awslambda • • Sep 25 '23

Looking for feedback on our pre alpha webassembly cloud for serverless applications

4 Upvotes

Hello, allow us to introduce NoOps.

NoOps is an exploratory project to discover what is currently possible with WebAssembly. We firmly believe it's the next big thing but needs real-world usage.
We encourage you to see what we've achieved. The current state of NoOps allows you to build serverless applications with ease.

  • Combine various programming languages within the same application.

  • Reduce tedious boilerplate code by using our templates.

  • Run your application for free on our cloud.

https://github.com/noopsio/noops
Try it out and leave your feedback!


r/awslambda • • Aug 22 '23

Lambda without permission to execute binary

4 Upvotes

Hi everyone,

I have a lambda implemented in Golang that executes a binary present in a layer. The lambda worked for some time but now gives errors when running the binary.

In the code, I am making use of the function `exec.CommandContext` of the `os/exec` package to run the command, and the permission denied error is returned.

What I have tried so far to solve the error

  • Reuploading the layer zip with exec perms both in the zip and the binary inside of it

  • Try running a `chmod +x` command before the execution but it returned error

From what I have searched I have not found anything related to lambda layer execution permission. In case someone has more knowledge regarding this I would really appreciate it 🙂.

Thx in advance 😀


r/awslambda • • May 01 '23

AWS Lambda Introduces Response Payload Streaming

Thumbnail
blog.kloudmate.com
4 Upvotes

r/awslambda • • Apr 08 '23

AWS Lambda function integration with external service

Thumbnail
adesigner.in
4 Upvotes

r/awslambda • • Mar 21 '23

Free workshop: Build a GymApp on AWS w/ chatGPT + Twilio

4 Upvotes

A hands-on workshop on how to build a Serverless app that sends you a daily gym workout plan by using AWS Lambda, ChatGPT and Twilio

Join us on the 24th of March for the first "Wardens Assembly" 🫂 which will be a hands-on demo workshop lead by Mohamed Labouardy on how to build a Serverless application that sends you a daily gym workout plan by using AWS Lambda, ChatGPT and Twilio. 🏋️‍♀️

We'll cover the following topics:

- Build a Serverless app in Golang with AWS Lambda ⚡

- Schedule Lambda on cron expression triggers 🔀

- Connect OpenAI API with AWS Lambda 🤖

- Send SMS with Twilio API 💬

- Automate deployment with GitHub Actions ⚙️

Promo video: https://www.youtube.com/watch?v=x6UJCcbwSTA

Event hosted on our community Discord server.

Join here: https://discord.gg/VtTc57cb?event=1085199832521637948


r/awslambda • • Mar 15 '23

Get Total Cost

4 Upvotes

Hello!

I'm currently working on a small project and a part of it is getting the cost from the previous month and from September 1st to the current date. I've been using the get_cost_and_usage() function but it prints out a long list of a bunch of details.

All I want is the total value of the cost that I can output onto a DynamoDB table.

If anyone has ideas please leave them below!!! Thanks in advance!


r/awslambda • • Feb 22 '23

Beginner help: Lambda not properly receiving messages from SQS?

4 Upvotes

Hello! I'm new to the AWS world (taking an AWS program), so forgive my beginner experience. I'm trying to create a lambda that simply receives messages from SQS, but I just can't seem to figure out what I'm missing. I have permissions and an SQS trigger properly set up. I'm sending messages straight through the SQS console for testing.

I'm printing the message.body to logs, but it's not showing up.

The SQS queue 'available messages' updates to 0 when the lambda is triggered. Not sure what I'm doing wrong.

SQS set up: all defaults.

import json
import boto3

sqs = boto3.resource('sqs', region_name='us-east-1')

def lambda_handler(event, context):
    
    queue = sqs.get_queue_by_name(QueueName='SendMessage_Test')
    
    messages = queue.receive_messages(MaxNumberOfMessages=10)
    
    for message in messages:
        print(message.body)
        
        message.delete()

r/awslambda • • Feb 09 '23

Python vs Typescript for AWS Serverless Development

4 Upvotes

Would love additional input on this:
We are building a bunch of new apps, and are debating towards Python & Typescript for backend dev. When I say debate, I actually mean our new VP of engineering just started and has TS exp, and continuously challenges us on why not TS for the backend.
So far our approach is the following:

  • backend team also includes Data Engineers that have years of exp with Python and do not plan on changing, and if ever certainly not TS.

  • ci/cd automation, devops type stuff our engineers have also only used Python (aside from bash/shell/etc) and have no interest in using TS because "that's just stupid"

  • other development that will reside in lambda, glue, etc... (serverless first), but also ecs and ec2 when it makes sense (serverless not for everything) is the area in debate.

Our main justification is that if all 3 areas are the same we can help each-other out, avoid the "hit by the bus" syndrome, overall everyone but the VP prefers Python and wishes to never use TS.

Aside from this, please provide any input if you can on why one or the other in addition to what I have. Also reasons to use TS as well.
Thanks


r/awslambda • • Nov 01 '22

Help with lambda, not triggering my SSM document??

4 Upvotes

So i've setup a lambda function which is below, and also an event bridge for my cloud watch alarm state change below under the lambda function. I'm a bit stuck with the SSM document, what do i need to enter exactly upon clicking 'automation' ? I basically need to run a powershell script, everytime one of my window services stopped from my cloudwatch alarm. I have cloud watch setup so everytime the domain goes down i get an alert, but i need to somehow make a SSM document which runs a powershell script to start the window service when it's down via cloud watch. Any idea guys?

Lambda function:

import os

import boto3

import json

ssm = boto3.client('ssm')

def lambda_handler(event, context):

InstanceId = os.environ['InstanceId']

ssmDocument = os.environ['SSM_DOCUMENT_NAME']

log_group = os.environ['AWS_LAMBDA_LOG_GROUP_NAME']

targetInstances = [InstanceId]

response = ssm.send_command(

InstanceIds=targetInstances,

DocumentName=ssmDocument,

DocumentVersion='$DEFAULT', # Parameters={"instance" : [json.dumps(instance)]}, # this isn't valid - instance is not defined, but if you need to pass params, here they are CloudWatchOutputConfig={ 'CloudWatchLogGroupName': log_group, 'CloudWatchOutputEnabled': True } )

Event bridge :

---

schemaVersion: "2.2"

description: "Command Document Example JSON Template"

mainSteps:

- action: "aws:runPowerShellScript"

name: "RunCommands"

inputs:

runCommand:

- "Restart-Service -Name ColdFusion 2018 Application Server"


r/awslambda • • Oct 19 '22

How do I use files in my lambda functions?

4 Upvotes

I need to open a text file and choose a random line in my python lambda function but I get a “file not found error” when I test it in AWS


r/awslambda • • Oct 15 '22

How do I send the metric response from the JSON file to Cloud watch using AWS Lambda function?

4 Upvotes

I have the metric response in a JSON file and I want to send the metrics, "Size" and "fileCreatedAt" to Cloudwatch. In the future, I would like to get the metrics from the S3 bucket in AWS, but for now I wanted to write a Sample Code.

This is the JSON File

{
"nextToken": "sample-token",
  "files": [
    {
      "id": "xxxa",
      "fileCreatedAt": "2021",
      "size": 1234,
      "dataSourceId": "xx32"
    },
    {
      "id": "xxxb",
      "fileCreatedAt": "2022",
      "size": 3560,
      "dataSourceId": "xx33"
    },
   
]
}

Program to Parse the JSON file

import json
response = open('/content/sample_data/sample.json')
data = json.load(response)
for i in data['files']:
print(i['id'])

The boto3 Sample Code

import boto3
cloudwatch = boto3.client('cloudwatch')
client.put_metric_data(
Namespace='JSON/AWS',
MetricData=[
{
'MetricName': 'filesize',
'Dimensions': [
{
"Name": "Size",
"Value": size
},
],
},
{
'MetricName': 'fileCreatedAt',
'Dimensions': [
{
"Name": "fileCreatedAt",
"Value": fileCreatedAt
},
],
},
]

I tried to write the code to read the metrics from the metric response in the JSON file and transfer the metrics using boto3. Unfortunately, I got stuck with the boto code and I don't know how to proceed further. Could someone please help me with this?


r/awslambda • • Oct 13 '22

Do lambda containers compete for memory?

4 Upvotes

Scenario:

i'm launching thousands of lambda functions, concurrently. They each pull a big chunk of data from S3, do some manipulation, and then write results.

(Yes, I understand that there are other ways to do this - this particular use case is not a good candidate for EMR, etc)

Each of these lambdas typically takes about 10 minutes, and maxes out at about 8-9GB of RAM (configured for 10GB / max RAM). They are very similar.

I'm seeing some behavior that I don't understand:

When I have many hundreds or thousands of containers running, some of these lambda instances will fail for lack of memory. I'll request to perform an operation on a data frame, and get an error about "unable to allocate x mb for an array with blah blah"

But, I can re-run with the exact parameters and sometimes succeed. Especially if I wait several minutes until there aren't as many containers running,

Since the size of my input does not change, and the size of my memory does not change, why would I only *sometimes* fail for lack of memory?

Logically, it leads me to think that the memory on the host machine is over-provisioned and I can't get my full requested amount unless it is available.

Can anyone confirm that or shed any light on this mystery for me?

Thanks!