anilkumarggk
anilkumarggk

Reputation: 186

Loading large python packages into AWS lambda function

I can't seem to get around this(below mentioned) error while trying to upload a function onto AWS lambda:

The Code tab failed to save. Reason: Unzipped size must be smaller than 262144000 bytes

I've zipped the function and all of it's dependencies and uploaded the zipped file to S3, and pasted the file's S3 URL at the lambda's prompt (upload a file from Amazon S3).

Any leads would be appreciated. Thanks

Upvotes: 3

Views: 4467

Answers (2)

Alexis N-o
Alexis N-o

Reputation: 3993

Adding to Entropic's answer, what about using something like pyminifier? This could be a very simple solution if the minification it performs is sufficient to reach the limit of 250 MB.

Also, if you are using the AWS SDK, you do not need to include it in your package as it is included in the Lambda execution environment. This could also save some space if it is the case.

Upvotes: 3

Entropic Thunder
Entropic Thunder

Reputation: 176

As kosa mentioned there is a hard limit at 250MB. This reddit thread had a few good ideas: https://www.reddit.com/r/aws/comments/4qrw9m/how_to_work_around_aws_lambdas_250mb_limit/

Most solutions along the lines of 1) Loading more code later, thus getting around the 250 limit 2) Split up the code into smaller pieces, which is more aws-lambda-ish anyway, and 3) use strip command like this guy: https://serverlesscode.com/post/scikitlearn-with-amazon-linux-container/

2 is probably the best way to go, if you can split it up.

Upvotes: 2

Related Questions