Costs related to AWS Lambda and S3 codes

Asked

Viewed 74 times

1

When an AWS Lambda function has codes that are saved in a Bucket in S3, access to the sources for each function started, respects the S3 cost policy?

An example would be, each function that starts the same lowers the S3 code and I pay the transfer rate and access rate as if I were myself accessing and downloading the file?

Thank you.

  • Yes, it’s a request like any other. Take a look at this documentation, below is an example quoting S3: https://aws.amazon.com/pt/lambda/pricing/

1 answer

1

The question is a bit confusing and the "every function that starts the same lowers the S3 code" part generates different interpretations, but let’s get to the point:

Function Code

If you are referring to Function Code vs Invoke(start of container execution) I do not believe that it "downloads" your code at each run.

First, the container can be reused for an indefinite period of time, so if the container is "hot" the execution can (or not) consider the code it has previously run.

Second, the "Cold start" of the container already takes a considerable time, now, imagine if the package(zip, jar and etc) has 50MB and the container needs to download the code at each run, the latency of this would be a little bizarre and its cost in S3 would also rise.

Although I don’t find the official documentation of how this core part works it doesn’t make much sense to believe that your code is downloaded at every run.

Note: Do a test, deploy version 1 of Lambda Function and then go to S3 (update only on S3) and update the package to version 2 (some different print and so on). See if during all runs version 2 has been used.

Resource Consumption in S3

If you are referring to the access your code makes to resources in S3 (example: your code uploads or downloads images) then yes the S3 cost policy is normally applied.

In case you discover something different post here, always found a little obscure the documentation of AWS.

  • Tom, I’m sorry for the confusing question, but I’m talking about Function Code. When I create an application through the Serverless Framework, it saves the code in a Bucket and links it to the lambda function so that it can be downloaded. At first it doesn’t really keep downloading every time it starts an execution because it may be hot, but when it is necessary, it will be that Amazon is charging access to S3 and Get from the file (.zip)?

  • 1

    So I also got that from your question. I believe that the core of aws does the GET file only once every new version you deploy. To validate this just deploy the Lambda Function and then remove the zip file that the Upou framework in S3, I believe that everything will continue to work normally without downloading your code every time the container "cools".

  • Show, really it is interesting if he download the code only once per stack update. I will give a tested, thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.