Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce the size of AWS Lambda code written in JAVA in Eclipse

I am an android developer and exploring Amazon AWS for my future appliaction as a backend option. I had explored various AWS services such as dynamoDB, S3, SES and cool lambda feature with JAVA. During my learing I found/prepared a code for creating thumbnail images for every image uploaded to S3 bucket. I successfully written the Lambda code in java in eclipse IDE and able to upload and use it using AWS console for the purpose it was intended.

My Concern is that when I uploaded the JAVA Lambda code to AWS it appears 49 MB in SIZE. When I seek for the reason I found that there are plenty of jars were used in project under AWS sdk for java. Is this normal or I can reduce the size of uploaded code anyhow. Please guide me How can I reduce the size efficiently. I also seen the node.js Lambda code for same and its in KBs only. Might bbe I am doing some wrong things.

Please Help...

like image 548
GouravJn Avatar asked Nov 27 '22 13:11

GouravJn


1 Answers

Simple answer - you're doing it right and package size can't be reduced to a size comparable to a node.js application.

For node.js lambda, amazon has AWS SDK libraries in place so you have to upload only your own code and third party libraries. But for java lambda, the AWS SDK must be packaged with the application.

But you can reduce package size by carefully selecting which libraries to include and excluding unnecessary dependencies.

like image 59
Andrew Kolpakov Avatar answered Dec 06 '22 07:12

Andrew Kolpakov